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

Local pop3 folders -- woot! Create folder, move or copy a message anywhere. Deleting folders not implemented yet. Issues 2189 and 2969.

This commit is contained in:
ashley willis 2012-01-09 04:45:11 -06:00
parent dedecedfe4
commit d1dc346475
5 changed files with 38 additions and 6 deletions

View File

@ -310,8 +310,11 @@ public class ChooseFolder extends K9ListActivity {
String toastText = "Creating WebDav Folders not currently implemented."; String toastText = "Creating WebDav Folders not currently implemented.";
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show(); Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
} else if (store instanceof Pop3Store) { } else if (store instanceof Pop3Store) {
String toastText = "Creating Local Folders not currently implemented."; boolean result = mAccount.getLocalStore().createFolder(folderName);
String toastText = "Creation of folder \"" + folderName +
((result) ? "\" succeeded." : "\" failed.");
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show(); Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
onRefresh(false);
} else { } else {
Log.d(K9.LOG_TAG, "Unhandled store type " + store.getClass()); Log.d(K9.LOG_TAG, "Unhandled store type " + store.getClass());
} }

View File

@ -499,8 +499,11 @@ public class FolderList extends K9ListActivity {
String toastText = "Creating WebDav Folders not currently implemented."; String toastText = "Creating WebDav Folders not currently implemented.";
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show(); Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
} else if (store instanceof Pop3Store) { } else if (store instanceof Pop3Store) {
String toastText = "Creating Local Folders not currently implemented."; boolean result = mAccount.getLocalStore().createFolder(folderName);
String toastText = "Creation of folder \"" + folderName +
((result) ? "\" succeeded." : "\" failed.");
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show(); Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
onRefresh(false);
} else { } else {
Log.d(K9.LOG_TAG, "Unhandled store type " + store.getClass()); Log.d(K9.LOG_TAG, "Unhandled store type " + store.getClass());
} }

View File

@ -64,7 +64,7 @@ import com.fsck.k9.mail.store.UnavailableStorageException;
import com.fsck.k9.mail.store.LocalStore.LocalFolder; import com.fsck.k9.mail.store.LocalStore.LocalFolder;
import com.fsck.k9.mail.store.LocalStore.LocalMessage; import com.fsck.k9.mail.store.LocalStore.LocalMessage;
import com.fsck.k9.mail.store.LocalStore.PendingCommand; import com.fsck.k9.mail.store.LocalStore.PendingCommand;
import com.fsck.k9.mail.store.Pop3Store;
/** /**
* Starts a long running (application) Thread that will run through commands * Starts a long running (application) Thread that will run through commands
@ -3168,7 +3168,13 @@ public class MessagingController implements Runnable {
public boolean isMoveCapable(Message message) { public boolean isMoveCapable(Message message) {
return !message.getUid().startsWith(K9.LOCAL_UID_PREFIX); boolean isPop3Store = false;
try {
isPop3Store = message.getFolder().getAccount().getRemoteStore() instanceof Pop3Store;
} catch (com.fsck.k9.mail.MessagingException me) {
Log.e(K9.LOG_TAG, "MessagingException trying to get remote store of message: " + me);
}
return (!message.getUid().startsWith(K9.LOCAL_UID_PREFIX) || isPop3Store);
} }
public boolean isCopyCapable(Message message) { public boolean isCopyCapable(Message message) {
return isMoveCapable(message); return isMoveCapable(message);
@ -3229,6 +3235,7 @@ public class MessagingController implements Runnable {
private void moveOrCopyMessageSynchronous(final Account account, final String srcFolder, final Message[] inMessages, private void moveOrCopyMessageSynchronous(final Account account, final String srcFolder, final Message[] inMessages,
final String destFolder, final boolean isCopy, MessagingListener listener) { final String destFolder, final boolean isCopy, MessagingListener listener) {
try { try {
Store localStore = account.getLocalStore(); Store localStore = account.getLocalStore();
Store remoteStore = account.getRemoteStore(); Store remoteStore = account.getRemoteStore();
@ -3245,7 +3252,7 @@ public class MessagingController implements Runnable {
List<String> uids = new LinkedList<String>(); List<String> uids = new LinkedList<String>();
for (Message message : inMessages) { for (Message message : inMessages) {
String uid = message.getUid(); String uid = message.getUid();
if (!uid.startsWith(K9.LOCAL_UID_PREFIX)) { if (!uid.startsWith(K9.LOCAL_UID_PREFIX) || remoteStore instanceof Pop3Store) {
uids.add(uid); uids.add(uid);
} }
} }
@ -3280,7 +3287,10 @@ public class MessagingController implements Runnable {
} }
} }
queueMoveOrCopy(account, srcFolder, destFolder, isCopy, origUidMap.keySet().toArray(EMPTY_STRING_ARRAY)); if (!(remoteStore instanceof Pop3Store)) { // don't sync pop3
queueMoveOrCopy(account, srcFolder, destFolder, isCopy,
origUidMap.keySet().toArray(EMPTY_STRING_ARRAY));
}
} }
processPendingCommands(account); processPendingCommands(account);

View File

@ -1045,6 +1045,11 @@ public class LocalStore extends Store implements Serializable {
public String type; public String type;
} }
public boolean createFolder(String name) throws com.fsck.k9.mail.MessagingException {
LocalFolder folder = new LocalFolder(name);
return folder.create(null);
}
public void createFolders(final List<LocalFolder> foldersToCreate, final int visibleLimit) throws UnavailableStorageException { public void createFolders(final List<LocalFolder> foldersToCreate, final int visibleLimit) throws UnavailableStorageException {
database.execute(true, new DbCallback<Void>() { database.execute(true, new DbCallback<Void>() {
@Override @Override

View File

@ -288,6 +288,17 @@ public class Pop3Store extends Store {
folder.close(); folder.close();
} }
@Override
public boolean isMoveCapable() {
return true;
}
@Override
public boolean isCopyCapable() {
return true;
}
class Pop3Folder extends Folder { class Pop3Folder extends Folder {
private Socket mSocket; private Socket mSocket;
private InputStream mIn; private InputStream mIn;