1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 21:22:26 -05:00

If the response for an APPEND command contains the APPENDUID response code, read the UID of the newly appended message from there.

This commit is contained in:
Apoorv Khatreja 2011-06-21 04:34:57 +05:30
parent 6c84e196aa
commit 970271dbf9

View File

@ -52,6 +52,7 @@ import android.content.Context;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.PowerManager; import android.os.PowerManager;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.beetstra.jutf7.CharsetProvider; import com.beetstra.jutf7.CharsetProvider;
@ -1617,6 +1618,31 @@ public class ImapStore extends Store {
while (response.more()); while (response.more());
} while (response.mTag == null); } while (response.mTag == null);
/*
* If the server supports UIDPLUS, then along with the APPEND response it will return an APPENDUID response code.
* e.g. 11 OK [APPENDUID 2 238268] APPEND completed
*
* We can use the UID included in this response to update our records.
*
* Code imported from AOSP Email as of git rev a5c3744a247e432acf9f571a9dfb55321c4baa1a
*/
Object responseList = response.get(1);
if (responseList instanceof ImapList) {
final ImapList appendList = (ImapList) responseList;
if ((appendList.size() >= 3) && appendList.getString(0).equals("APPENDUID")) {
String serverUid = appendList.getString(2);
if (!TextUtils.isEmpty(serverUid)) {
message.setUid(serverUid);
continue;
}
}
}
/*
* This part is executed in case the server does not support UIDPLUS or does not implement the APPENDUID response code.
*/
String newUid = getUidFromMessageId(message); String newUid = getUidFromMessageId(message);
if (K9.DEBUG) if (K9.DEBUG)
Log.d(K9.LOG_TAG, "Got UID " + newUid + " for message for " + getLogId()); Log.d(K9.LOG_TAG, "Got UID " + newUid + " for message for " + getLogId());