1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 10:22:15 -05:00

Made some cosmetic changes for clarity, added debug messages for erroneous conditions. Fixed potential NPE in ImapFolder.parseSequenceSet().

This commit is contained in:
Apoorv Khatreja 2011-07-25 06:50:26 +05:30
parent 3321ebdc33
commit da9a5e6c17
2 changed files with 23 additions and 9 deletions

View File

@ -866,6 +866,7 @@ public class ImapStore extends Store {
if ((copyList.size() >= 4) && copyList.getString(0).equals("COPYUID")) { if ((copyList.size() >= 4) && copyList.getString(0).equals("COPYUID")) {
List<String> srcUids = parseSequenceSet(copyList.getString(2)); List<String> srcUids = parseSequenceSet(copyList.getString(2));
List<String> destUids = parseSequenceSet(copyList.getString(3)); List<String> destUids = parseSequenceSet(copyList.getString(3));
if (srcUids != null && destUids != null) {
if (srcUids.size() == destUids.size()) { if (srcUids.size() == destUids.size()) {
Iterator<String> srcUidsIterator = srcUids.iterator(); Iterator<String> srcUidsIterator = srcUids.iterator();
Iterator<String> destUidsIterator = destUids.iterator(); Iterator<String> destUidsIterator = destUids.iterator();
@ -873,8 +874,18 @@ public class ImapStore extends Store {
while (srcUidsIterator.hasNext() && destUidsIterator.hasNext()) { while (srcUidsIterator.hasNext() && destUidsIterator.hasNext()) {
uidMap.put(srcUidsIterator.next(), destUidsIterator.next()); uidMap.put(srcUidsIterator.next(), destUidsIterator.next());
} }
} else {
if(K9.DEBUG)
Log.v(K9.LOG_TAG, "Parse error: size of source UIDs list is not the same as size of destination UIDs list.");
}
} else {
if(K9.DEBUG)
Log.v(K9.LOG_TAG, "Parsing of the sequence set failed.");
} }
} }
} else {
if(K9.DEBUG)
Log.v(K9.LOG_TAG, "Expected COPYUID response was not found.");
} }
return uidMap; return uidMap;
} catch (IOException ioe) { } catch (IOException ioe) {
@ -890,6 +901,9 @@ public class ImapStore extends Store {
* @return List<String> sequenceSet * @return List<String> sequenceSet
*/ */
private List<String> parseSequenceSet(String set) { private List<String> parseSequenceSet(String set) {
if (set == null) {
return null;
}
int index = 0; int index = 0;
List<String> sequenceList = new ArrayList<String>(); List<String> sequenceList = new ArrayList<String>();
String element = ""; String element = "";

View File

@ -2049,11 +2049,11 @@ public class LocalStore extends Store implements Serializable {
uid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString(); uid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
message.setUid(uid); message.setUid(uid);
} else if (copy) { } else if (copy) {
String temp = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString(); String randomLocalUid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
if (uid != null) { if (uid != null) {
uidMap.put(uid, temp); uidMap.put(uid, randomLocalUid);
} }
uid = temp; uid = randomLocalUid;
} else { } else {
Message oldMessage = getMessage(uid); Message oldMessage = getMessage(uid);
if (oldMessage != null && !oldMessage.isSet(Flag.SEEN)) { if (oldMessage != null && !oldMessage.isSet(Flag.SEEN)) {