mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-10 05:08:18 -05:00
Some refactoring. Added LocalFolder flag "local_only".
MessagingController.updateUids(): syncs UIDs in processPendingMoveOrCopy(), instead of messages being redownloaded. MessagingController.saveMessage(): unsynced messages can be moved, and therefore all messages are move/copy-capable.
This commit is contained in:
parent
c0aeca2d54
commit
8e77bb15e5
@ -28,8 +28,6 @@ import com.fsck.k9.mail.Folder;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.Store;
|
||||
import com.fsck.k9.mail.store.ImapStore;
|
||||
import com.fsck.k9.mail.store.LocalStore;
|
||||
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
|
||||
import com.fsck.k9.mail.store.Pop3Store;
|
||||
import com.fsck.k9.mail.store.WebDavStore;
|
||||
import java.util.ArrayList;
|
||||
@ -310,7 +308,7 @@ public class ChooseFolder extends K9ListActivity {
|
||||
String toastText = "Creating WebDav Folders not currently implemented.";
|
||||
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
|
||||
} else if (store instanceof Pop3Store) {
|
||||
boolean result = mAccount.getLocalStore().createFolder(folderName);
|
||||
boolean result = mAccount.getLocalStore().createFolder(folderName, true);
|
||||
String toastText = "Creation of folder \"" + folderName +
|
||||
((result) ? "\" succeeded." : "\" failed.");
|
||||
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
|
||||
|
@ -37,7 +37,6 @@ import com.fsck.k9.mail.Folder;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.Store;
|
||||
import com.fsck.k9.mail.store.ImapStore;
|
||||
import com.fsck.k9.mail.store.LocalStore;
|
||||
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
|
||||
import com.fsck.k9.mail.store.Pop3Store;
|
||||
import com.fsck.k9.mail.store.WebDavStore;
|
||||
@ -422,18 +421,8 @@ public class FolderList extends K9ListActivity {
|
||||
onRefresh(false);
|
||||
}
|
||||
|
||||
|
||||
private void onRefresh(boolean forceRemote) {
|
||||
// Pop3 does not have remote folders, so if this is true the local folders will be deleted!
|
||||
try {
|
||||
if (mAccount.getRemoteStore() instanceof Pop3Store) {
|
||||
forceRemote = false;
|
||||
}
|
||||
} catch (com.fsck.k9.mail.MessagingException me) {
|
||||
Log.e(K9.LOG_TAG, "Error getting the remote store: " + me);
|
||||
}
|
||||
MessagingController.getInstance(getApplication()).listFolders(mAccount, forceRemote, mAdapter.mListener);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -507,7 +496,7 @@ public class FolderList extends K9ListActivity {
|
||||
String toastText = "Creating WebDav Folders not currently implemented.";
|
||||
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
|
||||
} else if (store instanceof Pop3Store) {
|
||||
boolean result = mAccount.getLocalStore().createFolder(folderName);
|
||||
boolean result = mAccount.getLocalStore().createFolder(folderName, true);
|
||||
String toastText = "Creation of folder \"" + folderName +
|
||||
((result) ? "\" succeeded." : "\" failed.");
|
||||
Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG).show();
|
||||
@ -734,7 +723,7 @@ public class FolderList extends K9ListActivity {
|
||||
/*
|
||||
Change special folder settings (when a folder is renamed or deleted).
|
||||
*/
|
||||
private void resetSpecialFolders(String oldFolderName, String newFolderName) {
|
||||
private void resetSpecialFolders(final String oldFolderName, final String newFolderName) {
|
||||
if (oldFolderName.equals(mAccount.getTrashFolderName())) {
|
||||
mAccount.setTrashFolderName(newFolderName);
|
||||
}
|
||||
|
@ -1760,15 +1760,6 @@ public class MessageList
|
||||
}
|
||||
|
||||
Account account = message.message.getFolder().getAccount();
|
||||
if (!mController.isCopyCapable(account)) {
|
||||
menu.findItem(R.id.copy).setVisible(false);
|
||||
}
|
||||
|
||||
if (!mController.isMoveCapable(account)) {
|
||||
menu.findItem(R.id.move).setVisible(false);
|
||||
menu.findItem(R.id.archive).setVisible(false);
|
||||
menu.findItem(R.id.spam).setVisible(false);
|
||||
}
|
||||
|
||||
if (K9.FOLDER_NONE.equalsIgnoreCase(account.getArchiveFolderName())) {
|
||||
menu.findItem(R.id.archive).setVisible(false);
|
||||
@ -2640,7 +2631,7 @@ public class MessageList
|
||||
* Never {@code null}.
|
||||
*/
|
||||
private void onMove(final List<MessageInfoHolder> holders) {
|
||||
if (!checkCopyOrMovePossible(holders, FolderOperation.MOVE)) {
|
||||
if (holders.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2655,7 +2646,7 @@ public class MessageList
|
||||
* Never {@code null}.
|
||||
*/
|
||||
private void onCopy(final List<MessageInfoHolder> holders) {
|
||||
if (!checkCopyOrMovePossible(holders, FolderOperation.COPY)) {
|
||||
if (holders.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2735,42 +2726,6 @@ public class MessageList
|
||||
COPY, MOVE
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an Toast message if any message isn't synchronized
|
||||
*
|
||||
* @param holders
|
||||
* Never <code>null</code>.
|
||||
* @param operation
|
||||
* Never {@code null}.
|
||||
*
|
||||
* @return <code>true</code> if operation is possible
|
||||
*/
|
||||
private boolean checkCopyOrMovePossible(final List<MessageInfoHolder> holders, final FolderOperation operation) {
|
||||
if (holders.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean first = true;
|
||||
for (final MessageInfoHolder holder : holders) {
|
||||
final Message message = holder.message;
|
||||
if (first) {
|
||||
first = false;
|
||||
// account check
|
||||
final Account account = message.getFolder().getAccount();
|
||||
if ((operation == FolderOperation.MOVE && !mController.isMoveCapable(account)) || (operation == FolderOperation.COPY && !mController.isCopyCapable(account))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// message check
|
||||
if ((operation == FolderOperation.MOVE && !mController.isMoveCapable(message)) || (operation == FolderOperation.COPY && !mController.isCopyCapable(message))) {
|
||||
final Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message,
|
||||
Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get a List of message ready to be processed. This implementation will return a list containing the sole argument.
|
||||
*
|
||||
@ -2848,25 +2803,11 @@ public class MessageList
|
||||
first = false;
|
||||
folderName = message.getFolder().getName();
|
||||
account = message.getFolder().getAccount();
|
||||
if ((operation == FolderOperation.MOVE && !mController.isMoveCapable(account)) || (operation == FolderOperation.COPY && !mController.isCopyCapable(account))) {
|
||||
// account is not copy/move capable
|
||||
return;
|
||||
}
|
||||
} else if (!account.equals(message.getFolder().getAccount())
|
||||
|| !folderName.equals(message.getFolder().getName())) {
|
||||
// make sure all messages come from the same account/folder?
|
||||
return;
|
||||
}
|
||||
if ((operation == FolderOperation.MOVE && !mController.isMoveCapable(message)) || (operation == FolderOperation.COPY && !mController.isCopyCapable(message))) {
|
||||
final Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message,
|
||||
Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
|
||||
// XXX return meaningful error value?
|
||||
|
||||
// message isn't synchronized
|
||||
return;
|
||||
}
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
|
@ -518,18 +518,13 @@ public class MessageView extends K9Activity implements OnClickListener {
|
||||
mDelete.setEnabled(true);
|
||||
mNext.setEnabled(mNextMessage != null);
|
||||
mPrevious.setEnabled(mPreviousMessage != null);
|
||||
// If moving isn't support at all, then all of them must be disabled anyway.
|
||||
if (mController.isMoveCapable(mAccount)) {
|
||||
// Only enable the button if the Archive folder is not the current folder and not NONE.
|
||||
mArchive.setEnabled(!mMessageReference.folderName.equals(mAccount.getArchiveFolderName()) &&
|
||||
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getArchiveFolderName()));
|
||||
// Only enable the button if the Spam folder is not the current folder and not NONE.
|
||||
mSpam.setEnabled(!mMessageReference.folderName.equals(mAccount.getSpamFolderName()) &&
|
||||
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName()));
|
||||
mMove.setEnabled(true);
|
||||
} else {
|
||||
disableMoveButtons();
|
||||
}
|
||||
// Only enable the button if the Archive folder is not the current folder and not NONE.
|
||||
mArchive.setEnabled(!mMessageReference.folderName.equals(mAccount.getArchiveFolderName()) &&
|
||||
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getArchiveFolderName()));
|
||||
// Only enable the button if the Spam folder is not the current folder and not NONE.
|
||||
mSpam.setEnabled(!mMessageReference.folderName.equals(mAccount.getSpamFolderName()) &&
|
||||
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName()));
|
||||
mMove.setEnabled(true);
|
||||
}
|
||||
private void staticButtons() {
|
||||
View buttons = findViewById(R.id.scrolling_buttons);
|
||||
@ -650,15 +645,6 @@ public class MessageView extends K9Activity implements OnClickListener {
|
||||
}
|
||||
|
||||
private void onRefile(String dstFolder) {
|
||||
if (!mController.isMoveCapable(mAccount)) {
|
||||
return;
|
||||
}
|
||||
if (!mController.isMoveCapable(mMessage)) {
|
||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (K9.FOLDER_NONE.equalsIgnoreCase(dstFolder)) {
|
||||
return;
|
||||
}
|
||||
@ -738,30 +724,16 @@ public class MessageView extends K9Activity implements OnClickListener {
|
||||
}
|
||||
|
||||
private void onMove() {
|
||||
if ((!mController.isMoveCapable(mAccount))
|
||||
|| (mMessage == null)) {
|
||||
if (mMessage == null) {
|
||||
return;
|
||||
}
|
||||
if (!mController.isMoveCapable(mMessage)) {
|
||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
return;
|
||||
}
|
||||
|
||||
startRefileActivity(ACTIVITY_CHOOSE_FOLDER_MOVE);
|
||||
}
|
||||
|
||||
private void onCopy() {
|
||||
if ((!mController.isCopyCapable(mAccount))
|
||||
|| (mMessage == null)) {
|
||||
if (mMessage == null) {
|
||||
return;
|
||||
}
|
||||
if (!mController.isCopyCapable(mMessage)) {
|
||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
return;
|
||||
}
|
||||
|
||||
startRefileActivity(ACTIVITY_CHOOSE_FOLDER_COPY);
|
||||
}
|
||||
|
||||
@ -1005,14 +977,6 @@ public class MessageView extends K9Activity implements OnClickListener {
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
getMenuInflater().inflate(R.menu.message_view_option, menu);
|
||||
if (!mController.isCopyCapable(mAccount)) {
|
||||
menu.findItem(R.id.copy).setVisible(false);
|
||||
}
|
||||
if (!mController.isMoveCapable(mAccount)) {
|
||||
menu.findItem(R.id.move).setVisible(false);
|
||||
menu.findItem(R.id.archive).setVisible(false);
|
||||
menu.findItem(R.id.spam).setVisible(false);
|
||||
}
|
||||
if (K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getArchiveFolderName())) {
|
||||
menu.findItem(R.id.archive).setVisible(false);
|
||||
}
|
||||
|
@ -110,7 +110,6 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
|
||||
|
||||
private Account mAccount;
|
||||
private boolean mIsMoveCapable = false;
|
||||
private boolean mIsPushCapable = false;
|
||||
private boolean mIsExpungeCapable = false;
|
||||
|
||||
@ -188,7 +187,6 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
|
||||
try {
|
||||
final Store store = mAccount.getRemoteStore();
|
||||
mIsMoveCapable = store.isMoveCapable();
|
||||
mIsPushCapable = store.isPushCapable();
|
||||
mIsExpungeCapable = store.isExpungeCapable();
|
||||
} catch (Exception e) {
|
||||
@ -442,11 +440,9 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
});
|
||||
|
||||
mAccountEnableMoveButtons = (CheckBoxPreference) findPreference(PREFERENCE_ENABLE_MOVE_BUTTONS);
|
||||
mAccountEnableMoveButtons.setEnabled(mIsMoveCapable);
|
||||
mAccountEnableMoveButtons.setChecked(mAccount.getEnableMoveButtons());
|
||||
|
||||
mAccountScrollMoveButtons = (ListPreference) findPreference(PREFERENCE_HIDE_MOVE_BUTTONS);
|
||||
mAccountScrollMoveButtons.setEnabled(mIsMoveCapable);
|
||||
mAccountScrollMoveButtons.setValue("" + mAccount.getScrollMessageViewMoveButtons());
|
||||
mAccountScrollMoveButtons.setSummary(mAccountScrollMoveButtons.getEntry());
|
||||
mAccountScrollMoveButtons.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@ -758,13 +754,8 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
mAccount.setMaxPushFolders(Integer.parseInt(mMaxPushFolders.getValue()));
|
||||
}
|
||||
|
||||
if (!mIsMoveCapable) {
|
||||
mAccount.setEnableMoveButtons(false);
|
||||
mAccount.setScrollMessageViewMoveButtons(ScrollButtons.NEVER);
|
||||
} else {
|
||||
mAccount.setEnableMoveButtons(mAccountEnableMoveButtons.isChecked());
|
||||
mAccount.setScrollMessageViewMoveButtons(Account.ScrollButtons.valueOf(mAccountScrollMoveButtons.getValue()));
|
||||
}
|
||||
mAccount.setEnableMoveButtons(mAccountEnableMoveButtons.isChecked());
|
||||
mAccount.setScrollMessageViewMoveButtons(Account.ScrollButtons.valueOf(mAccountScrollMoveButtons.getValue()));
|
||||
|
||||
boolean needsRefresh = mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue()));
|
||||
needsRefresh |= mAccount.setFolderSyncMode(Account.FolderMode.valueOf(mSyncMode.getValue()));
|
||||
|
@ -449,7 +449,7 @@ public class MessagingController implements Runnable {
|
||||
put("doRefreshRemote", listener, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List <? extends Folder > localFolders = null;
|
||||
List <? extends LocalFolder > localFolders = null;
|
||||
try {
|
||||
Store store = account.getRemoteStore();
|
||||
|
||||
@ -476,13 +476,22 @@ public class MessagingController implements Runnable {
|
||||
localFolders = localStore.getPersonalNamespaces(false);
|
||||
|
||||
/*
|
||||
* Clear out any folders that are no longer on the remote store.
|
||||
* Clear out any folders that are no longer on the remote store,
|
||||
* unless they are tagged as local-only or are special folders.
|
||||
*/
|
||||
for (Folder localFolder : localFolders) {
|
||||
// ASH todo: also don't clear out folders with K9.LOCAL_UID_PREFIX
|
||||
for (LocalFolder localFolder : localFolders) {
|
||||
String localFolderName = localFolder.getName();
|
||||
if (!account.isSpecialFolder(localFolderName) && !remoteFolderNames.contains(localFolderName)) {
|
||||
if (!account.isSpecialFolder(localFolderName) &&
|
||||
!remoteFolderNames.contains(localFolderName) &&
|
||||
!localFolder.isLocalOnly()) {
|
||||
localFolder.delete(false);
|
||||
}
|
||||
if (remoteFolderNames.contains(localFolderName)) {
|
||||
if (localFolder.isLocalOnly()) localFolder.setLocalOnly(false);
|
||||
} else if (localFolder.exists()) {
|
||||
if (!localFolder.isLocalOnly()) localFolder.setLocalOnly(true);
|
||||
}
|
||||
}
|
||||
|
||||
localFolders = localStore.getPersonalNamespaces(false);
|
||||
@ -620,8 +629,9 @@ public class MessagingController implements Runnable {
|
||||
* Find all messages in any local account which match the query 'query'
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public void searchLocalMessages(final String[] accountUuids, final String[] folderNames, final Message[] messages, final String query, final boolean integrate,
|
||||
final Flag[] requiredFlags, final Flag[] forbiddenFlags, final MessagingListener listener) {
|
||||
public void searchLocalMessages(final String[] accountUuids, final String[] folderNames, final
|
||||
Message[] messages, final String query, final boolean integrate, final Flag[]
|
||||
requiredFlags, final Flag[] forbiddenFlags, final MessagingListener listener) {
|
||||
if (K9.DEBUG) {
|
||||
Log.i(K9.LOG_TAG, "searchLocalMessages ("
|
||||
+ "accountUuids=" + Utility.combine(accountUuids, ',')
|
||||
@ -637,11 +647,15 @@ public class MessagingController implements Runnable {
|
||||
threadPool.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchLocalMessagesSynchronous(accountUuids, folderNames, messages, query, integrate, requiredFlags, forbiddenFlags, listener);
|
||||
searchLocalMessagesSynchronous(accountUuids, folderNames, messages, query,
|
||||
integrate, requiredFlags, forbiddenFlags, listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void searchLocalMessagesSynchronous(final String[] accountUuids, final String[] folderNames, final Message[] messages, final String query, final boolean integrate, final Flag[] requiredFlags, final Flag[] forbiddenFlags, final MessagingListener listener) {
|
||||
public void searchLocalMessagesSynchronous(final String[] accountUuids, final String[]
|
||||
folderNames, final Message[] messages, final String query, final boolean integrate,
|
||||
final Flag[] requiredFlags, final Flag[] forbiddenFlags, final MessagingListener
|
||||
listener) {
|
||||
|
||||
final AccountStats stats = new AccountStats();
|
||||
final Set<String> accountUuidsSet = new HashSet<String>();
|
||||
@ -1939,12 +1953,9 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a pending append message command. This command uploads a local message to the
|
||||
* server, first checking to be sure that the server message is not newer than
|
||||
* the local message. Once the local message is successfully processed it is deleted so
|
||||
* that the server message will be synchronized down without an additional copy being
|
||||
* created.
|
||||
* TODO update the local message UID instead of deleteing it
|
||||
* Process a pending append message command. This command uploads a local message to the server,
|
||||
* first checking to be sure that the server message is not newer than the local message. Once
|
||||
* the local message is successfully processed its UID is updated to reflect the remote UID.
|
||||
*
|
||||
* @param command arguments = (String folder, String uid)
|
||||
* @param account
|
||||
@ -2090,7 +2101,7 @@ public class MessagingController implements Runnable {
|
||||
queuePendingCommand(account, command);
|
||||
}
|
||||
/**
|
||||
* Process a pending trash message command.
|
||||
* Process a pending move or copy message command.
|
||||
*
|
||||
* @param command arguments = (String folder, String uid)
|
||||
* @param account
|
||||
@ -2144,6 +2155,9 @@ public class MessagingController implements Runnable {
|
||||
destFolderName = null;
|
||||
}
|
||||
remoteSrcFolder.delete(messages.toArray(EMPTY_MESSAGE_ARRAY), destFolderName);
|
||||
if (destFolderName != null) {
|
||||
updateUids(account, destFolderName);
|
||||
}
|
||||
} else {
|
||||
remoteDestFolder = remoteStore.getFolder(destFolder);
|
||||
|
||||
@ -2152,7 +2166,9 @@ public class MessagingController implements Runnable {
|
||||
} else {
|
||||
remoteSrcFolder.moveMessages(messages.toArray(EMPTY_MESSAGE_ARRAY), remoteDestFolder);
|
||||
}
|
||||
updateUids(account, destFolder);
|
||||
}
|
||||
|
||||
if (!isCopy && Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
|
||||
if (K9.DEBUG)
|
||||
Log.i(K9.LOG_TAG, "processingPendingMoveOrCopy expunging folder " + account.getDescription() + ":" + srcFolder);
|
||||
@ -2167,6 +2183,84 @@ public class MessagingController implements Runnable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all messages in a folder with UIDs starting with K9.LOCAL_UID_PREFIX to their remote
|
||||
* UIDs, or APPEND the messages if not found on server.
|
||||
*
|
||||
* @param account Account we are saving for.
|
||||
* @param folder Folder to update.
|
||||
* @throws MessagingException
|
||||
*/
|
||||
private void updateUids(Account account, final String folder) throws MessagingException {
|
||||
Folder remoteFolder = null;
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
LocalFolder localFolder = localStore.getFolder(folder);
|
||||
localFolder.open(OpenMode.READ_WRITE);
|
||||
String[] queryFields = { "uid" };
|
||||
String queryString = K9.LOCAL_UID_PREFIX;
|
||||
List<LocalFolder> folders = Arrays.asList(new LocalFolder[] { localFolder });
|
||||
Message[] localMessages = localStore.searchForMessages(null, new String[] { "uid" }, queryString, folders, null, null, null);
|
||||
|
||||
try {
|
||||
if (localMessages.length == 0) {
|
||||
Log.w(K9.LOG_TAG, "No messages in local folder " + folder + " found with uid starting with " + K9.LOCAL_UID_PREFIX);
|
||||
return;
|
||||
}
|
||||
Store remoteStore = account.getRemoteStore();
|
||||
remoteFolder = remoteStore.getFolder(folder);
|
||||
if (!remoteFolder.exists()) {
|
||||
if (!remoteFolder.create()) {
|
||||
// ASH log something?
|
||||
return;
|
||||
}
|
||||
}
|
||||
remoteFolder.open(OpenMode.READ_WRITE);
|
||||
if (remoteFolder.getMode() != OpenMode.READ_WRITE) {
|
||||
// ASH log something?
|
||||
return;
|
||||
}
|
||||
|
||||
for (Message message : localMessages) {
|
||||
LocalMessage localMessage = (LocalMessage)message;
|
||||
|
||||
Log.w(K9.LOG_TAG, "Checking for remote message with same message id as local message with uid "
|
||||
+ localMessage.getUid());
|
||||
String rUid = remoteFolder.getUidFromMessageId(localMessage);
|
||||
if (rUid != null) {
|
||||
Log.w(K9.LOG_TAG, "Found a remote message with uid " + rUid);
|
||||
|
||||
String oldUid = localMessage.getUid();
|
||||
localMessage.setUid(rUid);
|
||||
localFolder.changeUid(localMessage);
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.messageUidChanged(account, folder, oldUid, localMessage.getUid());
|
||||
}
|
||||
} else {
|
||||
Log.w(K9.LOG_TAG, "No remote message with message-id found, appending instead.");
|
||||
/*
|
||||
* If the message does not exist remotely we just upload it and then
|
||||
* update our local copy with the new uid.
|
||||
*/
|
||||
FetchProfile fp = new FetchProfile();
|
||||
fp.add(FetchProfile.Item.BODY);
|
||||
localFolder.fetch(new Message[] { localMessage } , fp, null);
|
||||
String oldUid = localMessage.getUid();
|
||||
localMessage.setFlag(Flag.X_REMOTE_COPY_STARTED, true);
|
||||
remoteFolder.appendMessages(new Message[] { localMessage });
|
||||
|
||||
localFolder.changeUid(localMessage);
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.messageUidChanged(account, folder, oldUid, localMessage.getUid());
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
closeFolder(localFolder);
|
||||
closeFolder(remoteFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void queueSetFlag(final Account account, final String folderName, final String newState, final String flag, final String[] uids) {
|
||||
putBackground("queueSetFlag " + account.getDescription() + ":" + folderName, null, new Runnable() {
|
||||
@Override
|
||||
@ -3164,42 +3258,6 @@ public class MessagingController implements Runnable {
|
||||
put("getFolderUnread:" + account.getDescription() + ":" + folderName, l, unreadRunnable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isMoveCapable(Message message) {
|
||||
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) {
|
||||
return isMoveCapable(message);
|
||||
}
|
||||
|
||||
public boolean isMoveCapable(final Account account) {
|
||||
try {
|
||||
Store localStore = account.getLocalStore();
|
||||
Store remoteStore = account.getRemoteStore();
|
||||
return localStore.isMoveCapable() && remoteStore.isMoveCapable();
|
||||
} catch (MessagingException me) {
|
||||
|
||||
Log.e(K9.LOG_TAG, "Exception while ascertaining move capability", me);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isCopyCapable(final Account account) {
|
||||
try {
|
||||
Store localStore = account.getLocalStore();
|
||||
Store remoteStore = account.getRemoteStore();
|
||||
return localStore.isCopyCapable() && remoteStore.isCopyCapable();
|
||||
} catch (MessagingException me) {
|
||||
Log.e(K9.LOG_TAG, "Exception while ascertaining copy capability", me);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public void moveMessages(final Account account, final String srcFolder, final Message[] messages, final String destFolder,
|
||||
final MessagingListener listener) {
|
||||
for (Message message : messages) {
|
||||
@ -3234,25 +3292,21 @@ public class MessagingController implements Runnable {
|
||||
|
||||
private void moveOrCopyMessageSynchronous(final Account account, final String srcFolder, final Message[] inMessages,
|
||||
final String destFolder, final boolean isCopy, MessagingListener listener) {
|
||||
|
||||
try {
|
||||
Store localStore = account.getLocalStore();
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
Store remoteStore = account.getRemoteStore();
|
||||
if (!isCopy && (!remoteStore.isMoveCapable() || !localStore.isMoveCapable())) {
|
||||
return;
|
||||
}
|
||||
if (isCopy && (!remoteStore.isCopyCapable() || !localStore.isCopyCapable())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Folder localSrcFolder = localStore.getFolder(srcFolder);
|
||||
Folder localDestFolder = localStore.getFolder(destFolder);
|
||||
LocalFolder localSrcFolder = localStore.getFolder(srcFolder);
|
||||
LocalFolder localDestFolder = localStore.getFolder(destFolder);
|
||||
|
||||
List<String> uids = new LinkedList<String>();
|
||||
List<String> localUids = new LinkedList<String>();
|
||||
for (Message message : inMessages) {
|
||||
String uid = message.getUid();
|
||||
if (!uid.startsWith(K9.LOCAL_UID_PREFIX) || remoteStore instanceof Pop3Store) {
|
||||
// ASH fixme: add all messages, and later handle local ones separately?
|
||||
if (!uid.startsWith(K9.LOCAL_UID_PREFIX)) {
|
||||
uids.add(uid);
|
||||
} else {
|
||||
localUids.add(uid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3264,9 +3318,11 @@ public class MessagingController implements Runnable {
|
||||
origUidMap.put(message.getUid(), message);
|
||||
}
|
||||
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.i(K9.LOG_TAG, "moveOrCopyMessageSynchronous: source folder = " + srcFolder
|
||||
+ ", " + messages.length + " messages, " + ", destination folder = " + destFolder + ", isCopy = " + isCopy);
|
||||
+ ", " + messages.length + " messages, " + ", destination folder = " +
|
||||
destFolder + ", isCopy = " + isCopy);
|
||||
}
|
||||
|
||||
if (isCopy) {
|
||||
FetchProfile fp = new FetchProfile();
|
||||
@ -3286,9 +3342,59 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (!(remoteStore instanceof Pop3Store)) { // don't sync pop3
|
||||
if (!localDestFolder.isLocalOnly() && ((!isCopy && remoteStore.isMoveCapable()) ||
|
||||
(isCopy && remoteStore.isCopyCapable()))) {
|
||||
queueMoveOrCopy(account, srcFolder, destFolder, isCopy,
|
||||
origUidMap.keySet().toArray(EMPTY_STRING_ARRAY));
|
||||
} else if (!isCopy && !localSrcFolder.isLocalOnly()) {
|
||||
queueSetFlag(account, srcFolder, Boolean.toString(true),
|
||||
Flag.DELETED.toString(),
|
||||
origUidMap.keySet().toArray(EMPTY_STRING_ARRAY));
|
||||
if (Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
|
||||
queueExpunge(account, srcFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// K9.LOCAL_UID_PREFIX messages:
|
||||
Message[] localMessages = localSrcFolder.getMessages(localUids.toArray(EMPTY_STRING_ARRAY), null);
|
||||
if (localMessages.length > 0) {
|
||||
Map<String, Message> origUidMap = new HashMap<String, Message>();
|
||||
|
||||
for (Message message : localMessages) {
|
||||
origUidMap.put(message.getUid(), message);
|
||||
}
|
||||
|
||||
if (K9.DEBUG) {
|
||||
Log.i(K9.LOG_TAG, "moveOrCopyMessageSynchronous: source folder = " + srcFolder +
|
||||
", " + localMessages.length + " messages, " + ", destination folder = "
|
||||
+ destFolder + ", isCopy = " + isCopy);
|
||||
}
|
||||
|
||||
if (!isCopy) {
|
||||
localSrcFolder.moveMessages(localMessages, localDestFolder);
|
||||
for (Map.Entry<String, Message> entry : origUidMap.entrySet()) {
|
||||
String origUid = entry.getKey();
|
||||
Message message = entry.getValue();
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.messageUidChanged(account, srcFolder, origUid, message.getUid());
|
||||
}
|
||||
unsuppressMessage(account, srcFolder, origUid);
|
||||
}
|
||||
}
|
||||
|
||||
FetchProfile fp = new FetchProfile();
|
||||
fp.add(FetchProfile.Item.ENVELOPE);
|
||||
fp.add(FetchProfile.Item.BODY);
|
||||
localSrcFolder.fetch(localMessages, fp, null);
|
||||
|
||||
if ((!localDestFolder.isLocalOnly()) && ((!isCopy && (remoteStore.isMoveCapable()))
|
||||
|| (isCopy && (remoteStore.isCopyCapable())))) {
|
||||
for (Message message : localMessages) {
|
||||
saveMessage(account, message, destFolder);
|
||||
}
|
||||
} else if (isCopy) {
|
||||
localSrcFolder.copyMessages(localMessages, localDestFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4069,10 +4175,22 @@ public class MessagingController implements Runnable {
|
||||
* @return Message representing the entry in the local store.
|
||||
*/
|
||||
public Message saveDraft(final Account account, final Message message) {
|
||||
return saveMessage(account, message, account.getDraftsFolderName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a message.
|
||||
* @param account Account we are saving for.
|
||||
* @param message Message to save.
|
||||
* @param folderName String to save to.
|
||||
* @return Message representing the entry in the local store.
|
||||
*/
|
||||
public Message saveMessage(final Account account, final Message message, final String
|
||||
folderName) {
|
||||
Message localMessage = null;
|
||||
try {
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
LocalFolder localFolder = localStore.getFolder(account.getDraftsFolderName());
|
||||
LocalFolder localFolder = localStore.getFolder(folderName);
|
||||
localFolder.open(OpenMode.READ_WRITE);
|
||||
// Save the message to the store.
|
||||
localFolder.appendMessages(new Message[] {
|
||||
@ -4092,7 +4210,7 @@ public class MessagingController implements Runnable {
|
||||
processPendingCommands(account);
|
||||
|
||||
} catch (MessagingException e) {
|
||||
Log.e(K9.LOG_TAG, "Unable to save message as draft.", e);
|
||||
Log.e(K9.LOG_TAG, "Unable to save message to " + folderName + ".", e);
|
||||
addErrorMessage(account, null, e);
|
||||
}
|
||||
return localMessage;
|
||||
|
@ -787,12 +787,13 @@ public class ImapStore extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean createFolder(String name) throws com.fsck.k9.mail.MessagingException {
|
||||
ImapFolder folder = new ImapFolder(this, name);
|
||||
public boolean createFolder(final String folderName) throws com.fsck.k9.mail.MessagingException {
|
||||
ImapFolder folder = new ImapFolder(this, folderName);
|
||||
return folder.create();
|
||||
}
|
||||
|
||||
public boolean renameFolder(String oldFolderName, String newFolderName) throws com.fsck.k9.mail.MessagingException {
|
||||
public boolean renameFolder(final String oldFolderName, final String newFolderName)
|
||||
throws com.fsck.k9.mail.MessagingException {
|
||||
ImapFolder oldFolder = new ImapFolder(this, oldFolderName);
|
||||
ImapFolder newFolder = new ImapFolder(this, newFolderName);
|
||||
if (oldFolder.exists() && !newFolder.exists()) {
|
||||
@ -801,8 +802,8 @@ public class ImapStore extends Store {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean deleteFolder(String name) throws com.fsck.k9.mail.MessagingException {
|
||||
ImapFolder folder = new ImapFolder(this, name);
|
||||
public boolean deleteFolder(final String folderName) throws com.fsck.k9.mail.MessagingException {
|
||||
ImapFolder folder = new ImapFolder(this, folderName);
|
||||
return ((ImapFolder)folder).deleteFolder();
|
||||
}
|
||||
|
||||
@ -815,10 +816,12 @@ public class ImapStore extends Store {
|
||||
public boolean isCopyCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPushCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpungeCapable() {
|
||||
return true;
|
||||
@ -1077,7 +1080,7 @@ public class ImapStore extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean rename(String newFolder) throws MessagingException {
|
||||
public boolean rename(final String newFolder) throws MessagingException {
|
||||
/*
|
||||
* This method needs to operate in the unselected mode as well as the selected mode
|
||||
* so we must get the connection ourselves if it's not there. We are specifically
|
||||
@ -1156,7 +1159,7 @@ public class ImapStore extends Store {
|
||||
|
||||
if (!exists(remoteDestName)) {
|
||||
/*
|
||||
* If the remote trash folder doesn't exist we try to create it.
|
||||
* If the remote folder doesn't exist we try to create it.
|
||||
*/
|
||||
if (K9.DEBUG)
|
||||
Log.i(K9.LOG_TAG, "IMAPMessage.copyMessages: attempting to create remote '" + remoteDestName + "' folder for " + getLogId());
|
||||
|
@ -103,10 +103,10 @@ public class LocalStore extends Store implements Serializable {
|
||||
+ "bcc_list, reply_to_list, attachment_count, internal_date, message_id, folder_id, preview ";
|
||||
|
||||
|
||||
static private String GET_FOLDER_COLS = "id, name, unread_count, visible_limit, last_updated, status, push_state, last_pushed, flagged_count, integrate, top_group, poll_class, push_class, display_class";
|
||||
static private String GET_FOLDER_COLS = "id, name, unread_count, visible_limit, last_updated, status, push_state, last_pushed, flagged_count, integrate, top_group, poll_class, push_class, display_class, local_only";
|
||||
|
||||
|
||||
protected static final int DB_VERSION = 43;
|
||||
protected static final int DB_VERSION = 44;
|
||||
|
||||
protected String uUid = null;
|
||||
|
||||
@ -163,8 +163,8 @@ public class LocalStore extends Store implements Serializable {
|
||||
db.execSQL("CREATE TABLE folders (id INTEGER PRIMARY KEY, name TEXT, "
|
||||
+ "last_updated INTEGER, unread_count INTEGER, visible_limit INTEGER, status TEXT, "
|
||||
+ "push_state TEXT, last_pushed INTEGER, flagged_count INTEGER default 0, "
|
||||
+ "integrate INTEGER, top_group INTEGER, poll_class TEXT, push_class TEXT, display_class TEXT"
|
||||
+ ")");
|
||||
+ "integrate INTEGER, top_group INTEGER, poll_class TEXT, push_class TEXT, display_class TEXT, "
|
||||
+ "local_only INTEGER default 0)");
|
||||
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS folder_name ON folders (name)");
|
||||
db.execSQL("DROP TABLE IF EXISTS messages");
|
||||
@ -366,6 +366,38 @@ public class LocalStore extends Store implements Serializable {
|
||||
Log.e(K9.LOG_TAG, "Error trying to fix the outbox folders", e);
|
||||
}
|
||||
}
|
||||
if (db.getVersion() < 44) {
|
||||
Log.d("ASH", "updatedb " + mAccount.getDescription());
|
||||
try {
|
||||
db.execSQL("ALTER TABLE folders ADD local_only INTEGER default 0");
|
||||
|
||||
List <? extends Folder > remoteFolders =
|
||||
mAccount.getRemoteStore().getPersonalNamespaces(false);
|
||||
HashSet<String> remoteFolderNames = new HashSet<String>();
|
||||
for (Folder remoteFolder : remoteFolders) {
|
||||
remoteFolderNames.add(remoteFolder.getName());
|
||||
}
|
||||
// ASH verify that this works properly -- still untested!
|
||||
List <? extends LocalFolder > localFolders = getPersonalNamespaces(true);
|
||||
for (LocalFolder localFolder : localFolders) {
|
||||
if (remoteFolderNames.contains(localFolder.getName()) == false) {
|
||||
db.execSQL("UPDATE messages SET local_only = 1 WHERE name = " +
|
||||
localFolder.getName());
|
||||
localFolder.setLocalOnly(true);
|
||||
Log.w(K9.LOG_TAG, "Setting folder " + localFolder.getName() +
|
||||
" to local-only folder.");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLiteException e) {
|
||||
if (! e.getMessage().startsWith("duplicate column name: local_only")) {
|
||||
throw e;
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
Log.e(K9.LOG_TAG, "MessagingException trying to update folders for local-only setting: "
|
||||
+ e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -626,7 +658,7 @@ public class LocalStore extends Store implements Serializable {
|
||||
|
||||
// TODO this takes about 260-300ms, seems slow.
|
||||
@Override
|
||||
public List <? extends Folder > getPersonalNamespaces(boolean forceListAll) throws MessagingException {
|
||||
public List <? extends LocalFolder > getPersonalNamespaces(boolean forceListAll) throws MessagingException {
|
||||
final List<LocalFolder> folders = new LinkedList<LocalFolder>();
|
||||
try {
|
||||
database.execute(false, new DbCallback < List <? extends Folder >> () {
|
||||
@ -638,7 +670,7 @@ public class LocalStore extends Store implements Serializable {
|
||||
cursor = db.rawQuery("SELECT " + GET_FOLDER_COLS + " FROM folders ORDER BY name ASC", null);
|
||||
while (cursor.moveToNext()) {
|
||||
LocalFolder folder = new LocalFolder(cursor.getString(1));
|
||||
folder.open(cursor.getInt(0), cursor.getString(1), cursor.getInt(2), cursor.getInt(3), cursor.getLong(4), cursor.getString(5), cursor.getString(6), cursor.getLong(7), cursor.getInt(8), cursor.getInt(9), cursor.getInt(10), cursor.getString(11), cursor.getString(12), cursor.getString(13));
|
||||
folder.open(cursor.getInt(0), cursor.getString(1), cursor.getInt(2), cursor.getInt(3), cursor.getLong(4), cursor.getString(5), cursor.getString(6), cursor.getLong(7), cursor.getInt(8), cursor.getInt(9), cursor.getInt(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getInt(14));
|
||||
|
||||
folders.add(folder);
|
||||
}
|
||||
@ -856,8 +888,9 @@ public class LocalStore extends Store implements Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Message[] searchForMessages(MessageRetrievalListener listener, String[] queryFields, String queryString,
|
||||
List<LocalFolder> folders, Message[] messages, final Flag[] requiredFlags, final Flag[] forbiddenFlags) throws MessagingException {
|
||||
public Message[] searchForMessages(MessageRetrievalListener listener, String[] queryFields,
|
||||
String queryString, List<LocalFolder> folders, Message[] messages, final Flag[]
|
||||
requiredFlags, final Flag[] forbiddenFlags) throws MessagingException {
|
||||
List<String> args = new LinkedList<String>();
|
||||
|
||||
StringBuilder whereClause = new StringBuilder();
|
||||
@ -1045,12 +1078,16 @@ public class LocalStore extends Store implements Serializable {
|
||||
public String type;
|
||||
}
|
||||
|
||||
public boolean createFolder(String name) throws com.fsck.k9.mail.MessagingException {
|
||||
LocalFolder folder = new LocalFolder(name);
|
||||
return folder.create();
|
||||
public boolean createFolder(final String folderName, final boolean localOnly)
|
||||
throws com.fsck.k9.mail.MessagingException {
|
||||
LocalFolder folder = new LocalFolder(folderName);
|
||||
if (folder.exists()) {
|
||||
return false;
|
||||
}
|
||||
return folder.create(localOnly);
|
||||
}
|
||||
|
||||
public boolean renameFolder(final String oldFolderName, String newFolderName)
|
||||
public boolean renameFolder(final String oldFolderName, final String newFolderName)
|
||||
throws com.fsck.k9.mail.MessagingException {
|
||||
LocalFolder oldFolder = new LocalFolder(oldFolderName);
|
||||
LocalFolder newFolder = new LocalFolder(newFolderName);
|
||||
@ -1079,7 +1116,13 @@ public class LocalStore extends Store implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void createFolders(final List<LocalFolder> foldersToCreate, final int visibleLimit) throws UnavailableStorageException {
|
||||
public void createFolders(final List<LocalFolder> foldersToCreate, final int visibleLimit)
|
||||
throws UnavailableStorageException {
|
||||
createFolders(foldersToCreate, visibleLimit, false);
|
||||
}
|
||||
|
||||
public void createFolders(final List<LocalFolder> foldersToCreate, final int visibleLimit,
|
||||
final boolean localOnly) throws UnavailableStorageException {
|
||||
database.execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
@ -1119,6 +1162,13 @@ public class LocalStore extends Store implements Serializable {
|
||||
prefHolder.integrate ? 1 : 0,
|
||||
});
|
||||
|
||||
try {
|
||||
folder.setLocalOnly(localOnly);
|
||||
} catch (MessagingException me) {
|
||||
Log.e(K9.LOG_TAG, "Exception trying to set local-only status of folder " +
|
||||
name + " to " + localOnly);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1142,6 +1192,7 @@ public class LocalStore extends Store implements Serializable {
|
||||
private boolean mInTopGroup = false;
|
||||
private String mPushState = null;
|
||||
private boolean mIntegrate = false;
|
||||
private boolean mLocalOnly = false;
|
||||
// mLastUid is used during syncs. It holds the highest UID within the local folder so we
|
||||
// know whether or not an unread message added to the local folder is actually "new" or not.
|
||||
private Integer mLastUid = null;
|
||||
@ -1191,11 +1242,11 @@ public class LocalStore extends Store implements Serializable {
|
||||
if (cursor.moveToFirst()) {
|
||||
int folderId = cursor.getInt(0);
|
||||
if (folderId > 0) {
|
||||
open(folderId, cursor.getString(1), cursor.getInt(2), cursor.getInt(3), cursor.getLong(4), cursor.getString(5), cursor.getString(6), cursor.getLong(7), cursor.getInt(8), cursor.getInt(9), cursor.getInt(10), cursor.getString(11), cursor.getString(12), cursor.getString(13));
|
||||
open(folderId, cursor.getString(1), cursor.getInt(2), cursor.getInt(3), cursor.getLong(4), cursor.getString(5), cursor.getString(6), cursor.getLong(7), cursor.getInt(8), cursor.getInt(9), cursor.getInt(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getInt(14));
|
||||
}
|
||||
} else {
|
||||
Log.w(K9.LOG_TAG, "Creating folder " + getName() + " with existing id " + getId());
|
||||
create();
|
||||
create(true); // ASH should this always be true?
|
||||
open(mode);
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
@ -1211,7 +1262,7 @@ public class LocalStore extends Store implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void open(int id, String name, int unreadCount, int visibleLimit, long lastChecked, String status, String pushState, long lastPushed, int flaggedCount, int integrate, int topGroup, String syncClass, String pushClass, String displayClass) throws MessagingException {
|
||||
private void open(int id, String name, int unreadCount, int visibleLimit, long lastChecked, String status, String pushState, long lastPushed, int flaggedCount, int integrate, int topGroup, String syncClass, String pushClass, String displayClass, int localOnly) throws MessagingException {
|
||||
mFolderId = id;
|
||||
mName = name;
|
||||
mUnreadMessageCount = unreadCount;
|
||||
@ -1229,7 +1280,8 @@ public class LocalStore extends Store implements Serializable {
|
||||
mDisplayClass = Folder.FolderClass.valueOf((displayClass == null) ? noClass : displayClass);
|
||||
mPushClass = Folder.FolderClass.valueOf((pushClass == null) ? noClass : pushClass);
|
||||
mSyncClass = Folder.FolderClass.valueOf((syncClass == null) ? noClass : syncClass);
|
||||
|
||||
mLocalOnly = localOnly == 1 ? true : false;
|
||||
Log.v("ASH", mAccount.getDescription() + ":" + name + " is " + (localOnly == 1 ? "local-only." : "remote."));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1278,13 +1330,21 @@ public class LocalStore extends Store implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean create(final int visibleLimit) throws MessagingException {
|
||||
return create(visibleLimit, false);
|
||||
}
|
||||
|
||||
public boolean create(final boolean localOnly) throws MessagingException {
|
||||
return create(mAccount.getDisplayCount(), localOnly);
|
||||
}
|
||||
|
||||
public boolean create(final int visibleLimit, final boolean localOnly)
|
||||
throws MessagingException {
|
||||
if (exists()) {
|
||||
throw new MessagingException("Folder " + mName + " already exists.");
|
||||
}
|
||||
List<LocalFolder> foldersToCreate = new ArrayList<LocalFolder>(1);
|
||||
foldersToCreate.add(this);
|
||||
LocalStore.this.createFolders(foldersToCreate, visibleLimit);
|
||||
|
||||
LocalStore.this.createFolders(foldersToCreate, visibleLimit, localOnly);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1487,6 +1547,16 @@ public class LocalStore extends Store implements Serializable {
|
||||
updateFolderColumn("integrate", mIntegrate ? 1 : 0);
|
||||
}
|
||||
|
||||
public void setLocalOnly(boolean localOnly) throws MessagingException {
|
||||
mLocalOnly = localOnly;
|
||||
Log.d("ASH", "setting folder " + mName + " to localOnly = " + localOnly);
|
||||
updateFolderColumn("local_only", localOnly == true ? "1" : "0");
|
||||
}
|
||||
|
||||
public boolean isLocalOnly() {
|
||||
return mLocalOnly;
|
||||
}
|
||||
|
||||
private String getPrefId(String name) {
|
||||
if (prefId == null) {
|
||||
prefId = uUid + "." + name;
|
||||
|
@ -288,17 +288,6 @@ public class Pop3Store extends Store {
|
||||
folder.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMoveCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopyCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class Pop3Folder extends Folder {
|
||||
private Socket mSocket;
|
||||
private InputStream mIn;
|
||||
|
Loading…
Reference in New Issue
Block a user