diff --git a/backend/jmap/build.gradle b/backend/jmap/build.gradle index cfd8995f6..c74ebd552 100644 --- a/backend/jmap/build.gradle +++ b/backend/jmap/build.gradle @@ -12,7 +12,7 @@ dependencies { api project(":backend:api") api "com.squareup.okhttp3:okhttp:${versions.okhttp}" - implementation "rs.ltt.jmap:jmap-client:0.2.4" + implementation "rs.ltt.jmap:jmap-client:0.3.0" implementation "com.jakewharton.timber:timber:${versions.timber}" testImplementation project(":mail:testing") diff --git a/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandRefreshFolderList.kt b/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandRefreshFolderList.kt index 671c86c26..8aa743839 100644 --- a/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandRefreshFolderList.kt +++ b/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandRefreshFolderList.kt @@ -46,7 +46,9 @@ internal class CommandRefreshFolderList( } private fun fetchMailboxes() { - val call = jmapClient.call(GetMailboxMethodCall(accountId)) + val call = jmapClient.call( + GetMailboxMethodCall.builder().accountId(accountId).build() + ) val response = call.getMainResponseBlocking() val foldersOnServer = response.list @@ -91,19 +93,24 @@ internal class CommandRefreshFolderList( private fun fetchMailboxChanges(state: String): UpdateState { val multiCall = jmapClient.newMultiCall() - val mailboxChangesCall = multiCall.call(ChangesMailboxMethodCall(accountId, state)) + val mailboxChangesCall = multiCall.call( + ChangesMailboxMethodCall.builder() + .accountId(accountId) + .sinceState(state) + .build() + ) val createdMailboxesCall = multiCall.call( - GetMailboxMethodCall( - accountId, - mailboxChangesCall.createResultReference(ResultReference.Path.CREATED) - ) + GetMailboxMethodCall.builder() + .accountId(accountId) + .idsReference(mailboxChangesCall.createResultReference(ResultReference.Path.CREATED)) + .build() ) val changedMailboxesCall = multiCall.call( - GetMailboxMethodCall( - accountId, - mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED), - mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED_PROPERTIES) - ) + GetMailboxMethodCall.builder() + .accountId(accountId) + .idsReference(mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED)) + .propertiesReference(mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED_PROPERTIES)) + .build() ) multiCall.execute() diff --git a/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandSync.kt b/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandSync.kt index 3fef1ab22..eea8d2bdc 100644 --- a/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandSync.kt +++ b/backend/jmap/src/main/java/com/fsck/k9/backend/jmap/CommandSync.kt @@ -78,8 +78,13 @@ class CommandSync( Timber.d("Fetching all messages in %s (%s)", backendFolder.name, folderServerId) } - val queryEmailMethod = QueryEmailMethodCall(accountId, createEmailQuery(folderServerId), limit) - val queryEmailCall = jmapClient.call(queryEmailMethod) + val queryEmailCall = jmapClient.call( + QueryEmailMethodCall.builder() + .accountId(accountId) + .query(createEmailQuery(folderServerId)) + .limit(limit) + .build() + ) val queryEmailResponse = queryEmailCall.getMainResponseBlocking() val queryState = if (queryEmailResponse.isCanCalculateChanges) queryEmailResponse.queryState else null val remoteServerIds = queryEmailResponse.ids.toSet() @@ -113,8 +118,13 @@ class CommandSync( Timber.d("Updating messages in %s (%s)", backendFolder.name, folderServerId) val emailQuery = createEmailQuery(folderServerId) - val queryChangesEmailMethod = QueryChangesEmailMethodCall(accountId, queryState, emailQuery) - val queryChangesEmailCall = jmapClient.call(queryChangesEmailMethod) + val queryChangesEmailCall = jmapClient.call( + QueryChangesEmailMethodCall.builder() + .accountId(accountId) + .sinceQueryState(queryState) + .query(emailQuery) + .build() + ) val queryChangesEmailResponse = try { queryChangesEmailCall.getMainResponseBlocking() @@ -200,8 +210,13 @@ class CommandSync( } private fun getEmailPropertiesFromServer(emailIdsChunk: List, properties: Array): List { - val getEmailMethod = GetEmailMethodCall(accountId, emailIdsChunk.toTypedArray(), properties) - val getEmailCall = jmapClient.call(getEmailMethod) + val getEmailCall = jmapClient.call( + GetEmailMethodCall.builder() + .accountId(accountId) + .ids(emailIdsChunk.toTypedArray()) + .properties(properties) + .build() + ) val getEmailResponse = getEmailCall.getMainResponseBlocking() return getEmailResponse.list.toList()