MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.61k stars 627 forks source link

Method SyncMessagesWithFolder not found on Android #1713

Open lukewaggoner-zz opened 6 years ago

lukewaggoner-zz commented 6 years ago

I'm using the Android version of MailCore2, and I don't have the SyncMessagesWithFolder(String folder, int requestKind, IndexSet uids, int modSeqValue) method available. My colleague is using this method on iOS, and I'm wondering why it doesn't exist on Android.

I looked in the source code, and it looks like syncMessagesWithFolder makes a call to syncMessagesByUID, leading me to believe that the result would be the same. However, in his app, changes to flags are returned in operation.messages(), while in mine althought the modSeqValue changes, operation.messages() is empty.

This is what I'm doing (in Kotlin):

val fOp = session.folderInfoOperation(folder)
val op = session.syncMessagesByUIDOperation(folder, requestKind, indexSet, modSeqValue)

fOp.start(object : OperationCallback{

    override fun succeeded() {

        val info = fOp.info()
        op?.start(object : OperationCallback {

            override fun succeeded() {

                Log.i(TAG, "SyncedMessages ${op.messages().size} | ${op.vanishedMessages()?.count()}")

                callback.onSyncFolderSuccess(info.modSequenceValue(), op.messages().toJson())
            }

            override fun failed(p0: MailException?) {

                callback.onSyncFolderFailure(p0?.message!!)
            }
        })
    }

    override fun failed(p0: MailException?) {

        callback.onSyncFolderFailure(p0?.message!!)
    }
})
lukewaggoner-zz commented 6 years ago

Turns out the reason I wasn't getting flag updates was because when I was passing in my UID indexSet, I was using a 0-based index, rather than 1-based. Pardon the expression, but why the hell would using 0 instead of 1 cause it to not return flags, but return everything else?