Merge branch 'readonly-p4-donut' into donut

This commit is contained in:
Andy Stadler 2009-04-24 11:56:00 -07:00 committed by The Android Open Source Project
commit a63e9a0c86
8 changed files with 47 additions and 14 deletions

View File

@ -957,12 +957,12 @@ public class MessagingController implements Runnable {
* @param account
* @throws MessagingException
*/
private void processPendingTrash(PendingCommand command, Account account)
private void processPendingTrash(PendingCommand command, final Account account)
throws MessagingException {
String folder = command.arguments[0];
String uid = command.arguments[1];
LocalStore localStore = (LocalStore) Store.getInstance(
final LocalStore localStore = (LocalStore) Store.getInstance(
account.getLocalStoreUri(), mApplication, null);
LocalFolder localFolder = (LocalFolder) localStore.getFolder(folder);
@ -998,7 +998,23 @@ public class MessagingController implements Runnable {
}
if (remoteTrashFolder.exists()) {
remoteFolder.copyMessages(new Message[] { remoteMessage }, remoteTrashFolder);
remoteFolder.copyMessages(new Message[] { remoteMessage }, remoteTrashFolder,
new Folder.MessageUpdateCallbacks() {
public void onMessageUidChange(Message message, String newUid)
throws MessagingException {
// update the UID in the local trash folder, because some stores will
// have to change it when copying to remoteTrashFolder
LocalFolder localTrashFolder =
(LocalFolder) localStore.getFolder(account.getTrashFolderName());
LocalMessage localMessage =
(LocalMessage) localTrashFolder.getMessage(message.getUid());
if(localMessage != null) {
localMessage.setUid(newUid);
localTrashFolder.updateMessage(localMessage);
}
}
}
);
}
remoteMessage.setFlag(Flag.DELETED, true);
@ -1369,7 +1385,7 @@ public class MessagingController implements Runnable {
message.setFlag(Flag.X_SEND_IN_PROGRESS, false);
localFolder.copyMessages(
new Message[] { message },
localSentFolder);
localSentFolder, null);
PendingCommand command = new PendingCommand();
command.command = PENDING_COMMAND_APPEND;
@ -1425,7 +1441,7 @@ public class MessagingController implements Runnable {
Folder localFolder = localStore.getFolder(folder);
Folder localTrashFolder = localStore.getFolder(account.getTrashFolderName());
localFolder.copyMessages(new Message[] { message }, localTrashFolder);
localFolder.copyMessages(new Message[] { message }, localTrashFolder, null);
message.setFlag(Flag.DELETED, true);
if (account.getDeletePolicy() == Account.DELETE_POLICY_ON_DELETE) {

View File

@ -122,7 +122,8 @@ public abstract class Folder {
public abstract void appendMessages(Message[] messages) throws MessagingException;
public abstract void copyMessages(Message[] msgs, Folder folder) throws MessagingException;
public abstract void copyMessages(Message[] msgs, Folder folder,
MessageUpdateCallbacks callbacks) throws MessagingException;
public abstract void setFlags(Message[] messages, Flag[] flags, boolean value)
throws MessagingException;
@ -200,6 +201,19 @@ public abstract class Folder {
Flag[] setFlags, Flag[] clearFlags) throws MessagingException;
}
/**
* Callback interface by which a folder can report UID changes caused by certain operations.
*/
public interface MessageUpdateCallbacks {
/**
* The operation caused the message's UID to change
* @param message The message for which the UID changed
* @param newUid The new UID for the message
*/
public void onMessageUidChange(Message message, String newUid)
throws MessagingException;
}
@Override
public String toString() {
return getName();

View File

@ -57,7 +57,8 @@ public class ExchangeFolderExample extends Folder {
}
@Override
public void copyMessages(Message[] msgs, Folder folder) throws MessagingException {
public void copyMessages(Message[] msgs, Folder folder, MessageUpdateCallbacks callbacks)
throws MessagingException {
// TODO Implement this function
}

View File

@ -29,7 +29,6 @@ import com.android.email.mail.MessagingException;
import com.android.email.mail.Part;
import com.android.email.mail.Store;
import com.android.email.mail.Transport;
import com.android.email.mail.Folder.PersistentDataCallbacks;
import com.android.email.mail.internet.MimeBodyPart;
import com.android.email.mail.internet.MimeHeader;
import com.android.email.mail.internet.MimeMessage;
@ -482,7 +481,8 @@ public class ImapStore extends Store {
}
@Override
public void copyMessages(Message[] messages, Folder folder) throws MessagingException {
public void copyMessages(Message[] messages, Folder folder,
MessageUpdateCallbacks callbacks) throws MessagingException {
checkOpen();
String[] uids = new String[messages.length];
for (int i = 0, count = messages.length; i < count; i++) {

View File

@ -878,7 +878,8 @@ public class LocalStore extends Store {
}
@Override
public void copyMessages(Message[] msgs, Folder folder) throws MessagingException {
public void copyMessages(Message[] msgs, Folder folder, MessageUpdateCallbacks callbacks)
throws MessagingException {
if (!(folder instanceof LocalFolder)) {
throw new MessagingException("copyMessages called with incorrect Folder");
}

View File

@ -28,7 +28,6 @@ import com.android.email.mail.MessagingException;
import com.android.email.mail.Store;
import com.android.email.mail.Transport;
import com.android.email.mail.Folder.OpenMode;
import com.android.email.mail.Folder.PersistentDataCallbacks;
import com.android.email.mail.internet.MimeMessage;
import com.android.email.mail.transport.LoggingInputStream;
import com.android.email.mail.transport.MailTransport;
@ -790,7 +789,8 @@ public class Pop3Store extends Store {
}
@Override
public void copyMessages(Message[] msgs, Folder folder) throws MessagingException {
public void copyMessages(Message[] msgs, Folder folder, MessageUpdateCallbacks callbacks)
throws MessagingException {
throw new UnsupportedOperationException("copyMessages is not supported in POP3");
}

View File

@ -31,7 +31,8 @@ public class MockFolder extends Folder {
}
@Override
public void copyMessages(Message[] msgs, Folder folder) throws MessagingException {
public void copyMessages(Message[] msgs, Folder folder,
MessageUpdateCallbacks callbacks) throws MessagingException {
// TODO Auto-generated method stub
}

View File

@ -241,7 +241,7 @@ public class Pop3StoreUnitTests extends AndroidTestCase {
// copyMessages() is unsupported
try {
mFolder.copyMessages(null, null);
mFolder.copyMessages(null, null, null);
fail("Exception not thrown by copyMessages()");
} catch (UnsupportedOperationException e) {
// expected - succeed