-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for CONDSTORE and QRESYNC #2607
Conversation
public List<ImapMessage> getChangedMessagesUsingCondstore(long modseq) throws MessagingException { | ||
checkOpen(); | ||
if (!supportsModSeq()) { | ||
throw new MessagingException(String.format(Locale.US, "Folder %s does not support modification " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the string on a new line so you don't have to build a new one every time.
Currently, the sync process is as follows :
When CONDSTORE is used :
Thoughts ? @Valodim @philipwhiuk @cketti |
description matches with my understanding of the algorithm. Regarding the other points:
|
final String queryString, final String[] placeHolders | ||
final MessageRetrievalListener<LocalMessage> listener, | ||
final LocalFolder folder, | ||
final String queryString, final String[] placeHolders | ||
) throws MessagingException { | ||
final List<LocalMessage> messages = new ArrayList<>(); | ||
final int j = database.execute(false, new DbCallback<Integer>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 7 tests in When running `android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f07018e in packages [android, org.robolectric.default]
The related line, For the failing tests in |
I believe this occurs because IntelliJ (and thus Android Studio)'s default Run Configuration is based on the project working directory not the module working directory ( When I run the tests for When I run your branch's tests in the same way they fail. A lot of the failures are due to this:
which should be fairly trivial to fix. |
@philipwhiuk thanks for the tip, setting the JUnit working directory did the trick |
0870342
to
dcd230c
Compare
68a688b
to
cf1bc5d
Compare
@@ -3,6 +3,7 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of making this a super object in terms of configuration. ImapConfig
would be a good name for a class that could house the new stuff being added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return hasCapability(Capabilities.CONDSTORE); | ||
} | ||
|
||
boolean isQresyncCapable() throws IOException, MessagingException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is isCondstoreCapable
public and this not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isCondstoreCapable
is used in the FolderSelectedStateCommand.getCommandLengthLimit()
method, which is in the selectedstate
subpackage.
if (response.hasOpenMode()) { | ||
this.mode = response.getOpenMode(); | ||
} | ||
if (response == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null check is pointless. Line 182 would throw an NPE before it got here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception is a very broad catch case. Try to narrow this down a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny, the ConcurrentHashMap.put()
method does not throw any checked exceptions, so this try/catch block is useless. I'm not sure why this was there in the first place. I moved around a lot of original code without modifying it.
} | ||
} | ||
|
||
private void handleExpungeResponses(List<ImapResponse> imapResponses) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really 'handle' the response - it just searches them for a higher mod seq.
updateHighestModSequenceFromResponses
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
new MessageRetrievalListener<ImapMessage>() { | ||
@Override | ||
public void messageStarted(String uid, int number, int ofTotal) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anything is required here ?
if (folderName.equals(account.getTrashFolderName()) || | ||
folderName.equals(account.getSentFolderName()) || | ||
folderName.equals(account.getDraftsFolderName())) { | ||
if (!remoteFolder.exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not combine these if's
to reduce the nesting a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -74,6 +75,8 @@ | |||
private static final long serialVersionUID = -1973296520918624767L; | |||
private static final int MAX_BODY_SIZE_FOR_DATABASE = 16 * 1024; | |||
static final long INVALID_MESSAGE_PART_ID = -1; | |||
private static final int INVALID_UID_VALIDITY = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefining the same constants as in the library. Maybe they should be visible if you need them here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
mFolderId = cursor.getInt(LocalStore.FOLDER_ID_INDEX); | ||
mName = cursor.getString(LocalStore.FOLDER_NAME_INDEX); | ||
mVisibleLimit = cursor.getInt(LocalStore.FOLDER_VISIBLE_LIMIT_INDEX); | ||
|
||
//The index check here is because of an issue that occurs while upgrading the db to V55 - at that point, the | ||
//uid_validity and highest_mod_Seq columns do not exist yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why we have DatabaseMigration...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the open(Cursor)
method is called when upgrading to V55, but the uid_validity
and highest_mod_seq
columns do not exist yet. They are added only in V61. There does not seem to be a reliable way to recreate the open(Cursor) method in MigrationTo61
.
|
||
catch (Exception e) { | ||
if (!"X_BAD_FLAG".equals(flag)) { | ||
Timber.w("Unable to parse flag %s", flag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not check for X_BAD_FLAG first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@philipwhiuk made the changes |
8e03dc0
to
7831ffe
Compare
39156ee
to
524d8ba
Compare
48d146b
to
33dc02c
Compare
33dc02c
to
75a0452
Compare
@Valodim @philipwhiuk I'm not sure why/how the |
possibly related to #2675? |
This PR does several things
MessagingController
into separate classes depending on the protocol (ImapSyncInteractor
for IMAP accounts andLegacySyncInteractor
for POP3 and WebDAV accounts)MessagingControllerPushReceiver
so that a normal synchronization is performed when untagged responses are received through IDLE, instead of response-specific actions. This synchronization is done through a separate connection instead of reusing the connection through which IDLE responses are received.