mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
xargs astyle --style=ansi --mode=java --indent-switches \
--indent=spaces=4 --convert-tabs --unpad=paren
This commit is contained in:
parent
5a85446779
commit
3914a78b53
@ -433,11 +433,12 @@ public class Account implements Serializable
|
||||
}
|
||||
|
||||
|
||||
public boolean getLeftHanded() {
|
||||
public boolean getLeftHanded()
|
||||
{
|
||||
return mLeftHanded;
|
||||
}
|
||||
|
||||
public void setLeftHanded(boolean leftie)
|
||||
public void setLeftHanded(boolean leftie)
|
||||
{
|
||||
mLeftHanded = leftie;
|
||||
}
|
||||
|
@ -524,19 +524,19 @@ public class K9 extends Application
|
||||
intent.putExtra(K9.Intents.EmailReceived.EXTRA_FROM_SELF, account.isAnIdentity(message.getFrom()));
|
||||
K9.this.sendBroadcast(intent);
|
||||
Log.d(K9.LOG_TAG, "Broadcasted: action=" + action
|
||||
+ " account=" + account.getDescription()
|
||||
+ " folder=" + folder
|
||||
+ " message uid=" + message.getUid()
|
||||
);
|
||||
+ " account=" + account.getDescription()
|
||||
+ " folder=" + folder
|
||||
+ " message uid=" + message.getUid()
|
||||
);
|
||||
|
||||
}
|
||||
catch (MessagingException e)
|
||||
{
|
||||
Log.w(K9.LOG_TAG, "Error: action=" + action
|
||||
+ " account=" + account.getDescription()
|
||||
+ " folder=" + folder
|
||||
+ " message uid=" + message.getUid()
|
||||
);
|
||||
+ " account=" + account.getDescription()
|
||||
+ " folder=" + folder
|
||||
+ " message uid=" + message.getUid()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,7 +557,7 @@ public class K9 extends Application
|
||||
{
|
||||
broadcastIntent(K9.Intents.EmailReceived.ACTION_EMAIL_RECEIVED, account, folder, message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
@ -739,7 +739,7 @@ public class MessagingController implements Runnable
|
||||
if (K9.DEBUG)
|
||||
{
|
||||
Log.d(K9.LOG_TAG, "SYNC: About to process pending commands for account " +
|
||||
account.getDescription() );
|
||||
account.getDescription());
|
||||
}
|
||||
try
|
||||
{
|
||||
@ -933,8 +933,8 @@ public class MessagingController implements Runnable
|
||||
if (K9.DEBUG)
|
||||
{
|
||||
Log.d(K9.LOG_TAG, "Done synchronizing folder " +
|
||||
account.getDescription() + ":" + folder + " @ " + new Date() +
|
||||
" with " + newMessages + " new messages");
|
||||
account.getDescription() + ":" + folder + " @ " + new Date() +
|
||||
" with " + newMessages + " new messages");
|
||||
}
|
||||
|
||||
for (MessagingListener l : getListeners())
|
||||
@ -1002,7 +1002,7 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
addErrorMessage(account, e);
|
||||
Log.e(K9.LOG_TAG, "Failed synchronizing folder " +
|
||||
account.getDescription() + ":" + folder + " @ " + new Date());
|
||||
account.getDescription() + ":" + folder + " @ " + new Date());
|
||||
|
||||
}
|
||||
|
||||
@ -1104,7 +1104,7 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final AtomicInteger progress = new AtomicInteger(0);
|
||||
final int todo = unsyncedMessages.size() + syncFlagMessages.size();
|
||||
for (MessagingListener l : getListeners())
|
||||
@ -1550,27 +1550,27 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void processPendingCommandsSynchronous(Account account) throws MessagingException
|
||||
{
|
||||
LocalStore localStore = (LocalStore) Store.getInstance(
|
||||
account.getLocalStoreUri(),
|
||||
mApplication);
|
||||
ArrayList<PendingCommand> commands = localStore.getPendingCommands();
|
||||
|
||||
|
||||
int progress = 0;
|
||||
int todo = commands.size();
|
||||
if (todo == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (MessagingListener l : getListeners())
|
||||
{
|
||||
l.pendingCommandsProcessing(account);
|
||||
l.synchronizeMailboxProgress(account, null, progress, todo);
|
||||
}
|
||||
|
||||
|
||||
PendingCommand processingCommand = null;
|
||||
try
|
||||
{
|
||||
@ -3150,9 +3150,9 @@ public class MessagingController implements Runnable
|
||||
|
||||
put("getAccountUnread:" + account.getDescription(), l, unreadRunnable);
|
||||
}
|
||||
|
||||
|
||||
public void getFolderUnreadMessageCount(final Account account, final String folderName,
|
||||
final MessagingListener l)
|
||||
final MessagingListener l)
|
||||
{
|
||||
Runnable unreadRunnable = new Runnable()
|
||||
{
|
||||
@ -4323,7 +4323,7 @@ public class MessagingController implements Runnable
|
||||
|
||||
int syncingTotalMessagesInMailbox;
|
||||
int syncingNumNewMessages;
|
||||
|
||||
|
||||
int folderCompleted = 0;
|
||||
int folderTotal = 0;
|
||||
String processingCommandTitle = null;
|
||||
@ -4473,7 +4473,7 @@ public class MessagingController implements Runnable
|
||||
if (processingStarted.processingCommandTitle != null)
|
||||
{
|
||||
other.pendingCommandStarted(processingStarted.account, processingStarted.processingCommandTitle);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4514,8 +4514,8 @@ public class MessagingController implements Runnable
|
||||
Memory memory = getMemory(account, null);
|
||||
memory.sendingState = MemorizingState.FAILED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void synchronizeMailboxProgress(Account account, String folderName, int completed, int total)
|
||||
{
|
||||
Memory memory = getMemory(account, folderName);
|
||||
@ -4523,15 +4523,15 @@ public class MessagingController implements Runnable
|
||||
memory.folderTotal = total;
|
||||
}
|
||||
|
||||
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
{
|
||||
Memory memory = getMemory(account, null);
|
||||
memory.processingState = MemorizingState.STARTED;
|
||||
memory.folderCompleted = 0;
|
||||
memory.folderTotal = 0;
|
||||
}
|
||||
public void pendingCommandsFinished(Account account)
|
||||
public void pendingCommandsFinished(Account account)
|
||||
{
|
||||
Memory memory = getMemory(account, null);
|
||||
memory.processingState = MemorizingState.FINISHED;
|
||||
@ -4541,7 +4541,7 @@ public class MessagingController implements Runnable
|
||||
Memory memory = getMemory(account, null);
|
||||
memory.processingCommandTitle = commandTitle;
|
||||
}
|
||||
|
||||
|
||||
public void pendingCommandCompleted(Account account, String commandTitle)
|
||||
{
|
||||
Memory memory = getMemory(account, null);
|
||||
|
@ -73,7 +73,7 @@ public class MessagingListener
|
||||
public void synchronizeMailboxStarted(Account account, String folder)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
|
||||
{}
|
||||
|
||||
@ -157,7 +157,7 @@ public class MessagingListener
|
||||
public void folderStatusChanged(Account account, String folderName, int unreadMessageCount)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void folderStatusChanged(Account account, String folderName)
|
||||
{
|
||||
}
|
||||
@ -197,12 +197,12 @@ public class MessagingListener
|
||||
String reason)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void pendingCommandsProcessing(Account account) {}
|
||||
public void pendingCommandsFinished(Account account) {}
|
||||
public void pendingCommandStarted(Account account, String commandTitle)
|
||||
{}
|
||||
|
||||
|
||||
public void pendingCommandCompleted(Account account, String commandTitle)
|
||||
{}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
|
||||
private Account mSelectedContextAccount;
|
||||
private int mUnreadMessageCount = 0;
|
||||
|
||||
|
||||
private AccountsHandler mHandler = new AccountsHandler();
|
||||
private AccountsAdapter mAdapter;
|
||||
|
||||
@ -109,7 +109,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
private void setViewTitle()
|
||||
{
|
||||
String dispString = mListener.formatHeader(Accounts.this, getString(R.string.accounts_title), mUnreadMessageCount);
|
||||
|
||||
|
||||
setTitle(dispString);
|
||||
}
|
||||
public void refreshTitle()
|
||||
@ -211,7 +211,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener);
|
||||
|
||||
mHandler.progress(false);
|
||||
|
||||
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
mHandler.progress(true);
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
|
||||
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
|
||||
{
|
||||
super.synchronizeMailboxProgress(account, folder, completed, total);
|
||||
@ -238,14 +238,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
mHandler.refreshTitle();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendPendingMessagesStarted(Account account)
|
||||
{
|
||||
super.sendPendingMessagesStarted(account);
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendPendingMessagesCompleted(Account account)
|
||||
{
|
||||
@ -253,7 +253,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void sendPendingMessagesFailed(Account account)
|
||||
{
|
||||
@ -261,12 +261,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
{
|
||||
super.pendingCommandsProcessing(account);
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
public void pendingCommandsFinished(Account account)
|
||||
public void pendingCommandsFinished(Account account)
|
||||
{
|
||||
super.pendingCommandsFinished(account);
|
||||
mHandler.refreshTitle();
|
||||
@ -282,7 +282,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
private static String UNREAD_MESSAGE_COUNTS = "unreadMessageCounts";
|
||||
@ -443,14 +443,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
|
||||
private void onOpenAccount(Account account, boolean startup)
|
||||
{
|
||||
if (K9.FOLDER_NONE.equals(account.getAutoExpandFolderName()))
|
||||
{
|
||||
FolderList.actionHandleAccount(this, account, startup);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageList.actionHandleFolder(this, account, account.getAutoExpandFolderName(), startup);
|
||||
}
|
||||
if (K9.FOLDER_NONE.equals(account.getAutoExpandFolderName()))
|
||||
{
|
||||
FolderList.actionHandleAccount(this, account, startup);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageList.actionHandleFolder(this, account, account.getAutoExpandFolderName(), startup);
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick(View view)
|
||||
|
@ -16,15 +16,15 @@ public class ActivityListener extends MessagingListener
|
||||
private int mFolderTotal = 0;
|
||||
private String mProcessingAccountDescription = null;
|
||||
private String mProcessingCommandTitle = null;
|
||||
|
||||
|
||||
public String formatHeader(Context context, String activityPrefix, int unreadMessageCount)
|
||||
{
|
||||
String operation = null;
|
||||
String progress = null;
|
||||
if (mLoadingAccountDescription != null || mSendingAccountDescription != null || mProcessingAccountDescription != null)
|
||||
{
|
||||
progress = (mFolderTotal > 0 ? context.getString(R.string.folder_progress, mFolderCompleted, mFolderTotal) : "" );
|
||||
|
||||
progress = (mFolderTotal > 0 ? context.getString(R.string.folder_progress, mFolderCompleted, mFolderTotal) : "");
|
||||
|
||||
if (mLoadingFolderName != null)
|
||||
{
|
||||
String displayName = mLoadingFolderName;
|
||||
@ -34,7 +34,7 @@ public class ActivityListener extends MessagingListener
|
||||
}
|
||||
operation = context.getString(R.string.status_loading_account_folder, mLoadingAccountDescription, displayName, progress);
|
||||
}
|
||||
|
||||
|
||||
else if (mSendingAccountDescription != null)
|
||||
{
|
||||
operation = context.getString(R.string.status_sending_account, mSendingAccountDescription, progress);
|
||||
@ -42,22 +42,22 @@ public class ActivityListener extends MessagingListener
|
||||
else if (mProcessingAccountDescription != null)
|
||||
{
|
||||
operation = context.getString(R.string.status_processing_account, mProcessingAccountDescription,
|
||||
mProcessingCommandTitle != null ? mProcessingCommandTitle : "",
|
||||
progress);
|
||||
mProcessingCommandTitle != null ? mProcessingCommandTitle : "",
|
||||
progress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operation = "";
|
||||
}
|
||||
|
||||
|
||||
return context.getString(R.string.activity_header_format, activityPrefix,
|
||||
(unreadMessageCount > 0 ? context.getString(R.string.activity_unread_count, unreadMessageCount) : ""),
|
||||
operation);
|
||||
|
||||
|
||||
(unreadMessageCount > 0 ? context.getString(R.string.activity_unread_count, unreadMessageCount) : ""),
|
||||
operation);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxFinished(
|
||||
Account account,
|
||||
@ -77,7 +77,7 @@ public class ActivityListener extends MessagingListener
|
||||
mFolderCompleted = 0;
|
||||
mFolderTotal = 0;
|
||||
}
|
||||
|
||||
|
||||
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
|
||||
{
|
||||
mFolderCompleted = completed;
|
||||
@ -92,32 +92,32 @@ public class ActivityListener extends MessagingListener
|
||||
mLoadingFolderName = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendPendingMessagesStarted(Account account)
|
||||
{
|
||||
mSendingAccountDescription = account.getDescription();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendPendingMessagesCompleted(Account account)
|
||||
{
|
||||
mSendingAccountDescription = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void sendPendingMessagesFailed(Account account)
|
||||
{
|
||||
mSendingAccountDescription = null;
|
||||
}
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
{
|
||||
mProcessingAccountDescription = account.getDescription();
|
||||
mFolderCompleted = 0;
|
||||
mFolderTotal = 0;
|
||||
}
|
||||
public void pendingCommandsFinished(Account account)
|
||||
public void pendingCommandsFinished(Account account)
|
||||
{
|
||||
mProcessingAccountDescription = null;
|
||||
}
|
||||
@ -125,7 +125,7 @@ public class ActivityListener extends MessagingListener
|
||||
{
|
||||
mProcessingCommandTitle = commandTitle;
|
||||
}
|
||||
|
||||
|
||||
public void pendingCommandCompleted(Account account, String commandTitle)
|
||||
{
|
||||
mProcessingCommandTitle = null;
|
||||
|
@ -63,9 +63,9 @@ public class FolderList extends K9ListActivity
|
||||
private FolderListHandler mHandler = new FolderListHandler();
|
||||
|
||||
private boolean mStartup = false;
|
||||
|
||||
|
||||
private int mUnreadMessageCount = 0;
|
||||
|
||||
|
||||
|
||||
class FolderListHandler extends Handler
|
||||
{
|
||||
@ -141,10 +141,10 @@ public class FolderList extends K9ListActivity
|
||||
private void setViewTitle()
|
||||
{
|
||||
String dispString = mAdapter.mListener.formatHeader(FolderList.this, getString(R.string.folder_list_title, mAccount.getDescription()), mUnreadMessageCount);
|
||||
|
||||
|
||||
setTitle(dispString);
|
||||
|
||||
|
||||
|
||||
|
||||
setTitle(dispString);
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ public class FolderList extends K9ListActivity
|
||||
savedFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER);
|
||||
}
|
||||
|
||||
if (mStartup
|
||||
if (mStartup
|
||||
&& initialFolder != null
|
||||
&& !K9.FOLDER_NONE.equals(initialFolder))
|
||||
{
|
||||
@ -397,7 +397,7 @@ public class FolderList extends K9ListActivity
|
||||
MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
|
||||
mAccount.refresh(Preferences.getPreferences(this));
|
||||
MessagingController.getInstance(getApplication()).getAccountUnreadCount(this, mAccount, mAdapter.mListener);
|
||||
|
||||
|
||||
onRefresh(!REFRESH_REMOTE);
|
||||
|
||||
NotificationManager notifMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
@ -854,8 +854,8 @@ public class FolderList extends K9ListActivity
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "Unable to get unreadMessageCount for " + mAccount.getDescription() + ":"
|
||||
+ folder.getName());
|
||||
Log.e(K9.LOG_TAG, "Unable to get unreadMessageCount for " + mAccount.getDescription() + ":"
|
||||
+ folder.getName());
|
||||
}
|
||||
|
||||
if (holder == null)
|
||||
@ -888,9 +888,9 @@ public class FolderList extends K9ListActivity
|
||||
mHandler.progress(true);
|
||||
mHandler.folderLoading(folder, true);
|
||||
mHandler.dataChanged();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
|
||||
{
|
||||
@ -903,7 +903,7 @@ public class FolderList extends K9ListActivity
|
||||
}
|
||||
mHandler.dataChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages)
|
||||
{
|
||||
@ -917,7 +917,7 @@ public class FolderList extends K9ListActivity
|
||||
mHandler.folderLoading(folder, false);
|
||||
|
||||
refreshFolder(account, folder);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -975,7 +975,7 @@ public class FolderList extends K9ListActivity
|
||||
}
|
||||
|
||||
mHandler.dataChanged();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1035,7 +1035,7 @@ public class FolderList extends K9ListActivity
|
||||
}
|
||||
|
||||
refreshFolder(account, mAccount.getOutboxFolderName());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1044,7 +1044,7 @@ public class FolderList extends K9ListActivity
|
||||
{
|
||||
super.sendPendingMessagesStarted(account);
|
||||
mHandler.refreshTitle();
|
||||
|
||||
|
||||
if (!account.equals(mAccount))
|
||||
{
|
||||
return;
|
||||
@ -1078,12 +1078,12 @@ public class FolderList extends K9ListActivity
|
||||
mHandler.accountSizeChanged(oldSize, newSize);
|
||||
|
||||
}
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
{
|
||||
super.pendingCommandsProcessing(account);
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
public void pendingCommandsFinished(Account account)
|
||||
public void pendingCommandsFinished(Account account)
|
||||
{
|
||||
super.pendingCommandsFinished(account);
|
||||
mHandler.refreshTitle();
|
||||
|
@ -107,7 +107,7 @@ public class MessageList
|
||||
|
||||
private Account mAccount;
|
||||
private int mUnreadMessageCount = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Stores the name of the folder that we want to open as soon as possible
|
||||
@ -231,7 +231,7 @@ public class MessageList
|
||||
displayName = getString(R.string.special_mailbox_name_inbox);
|
||||
}
|
||||
String dispString = mAdapter.mListener.formatHeader(MessageList.this, getString(R.string.message_list_title, mAccount.getDescription(), displayName), mUnreadMessageCount);
|
||||
|
||||
|
||||
setTitle(dispString);
|
||||
int level = Window.PROGRESS_END;
|
||||
if (mCurrentFolder.loading && mAdapter.mListener.getFolderTotal() > 0)
|
||||
@ -242,7 +242,7 @@ public class MessageList
|
||||
level = Window.PROGRESS_END;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, level);
|
||||
}
|
||||
});
|
||||
@ -258,7 +258,7 @@ public class MessageList
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -441,9 +441,9 @@ public class MessageList
|
||||
notifMgr.cancel(-1000 - mAccount.getAccountNumber());
|
||||
|
||||
controller.getFolderUnreadMessageCount(mAccount, mFolderName, mAdapter.mListener);
|
||||
|
||||
|
||||
mHandler.refreshTitle();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1435,7 +1435,7 @@ public class MessageList
|
||||
public void synchronizeMailboxStarted(Account account, String folder)
|
||||
{
|
||||
super.synchronizeMailboxStarted(account, folder);
|
||||
|
||||
|
||||
if (account.equals(mAccount) && folder.equals(mFolderName))
|
||||
{
|
||||
mHandler.progress(true);
|
||||
@ -1451,7 +1451,7 @@ public class MessageList
|
||||
int totalMessagesInMailbox, int numNewMessages)
|
||||
{
|
||||
super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages);
|
||||
|
||||
|
||||
if (account.equals(mAccount) && folder.equals(mFolderName))
|
||||
{
|
||||
mHandler.progress(false);
|
||||
@ -1465,7 +1465,7 @@ public class MessageList
|
||||
public void synchronizeMailboxFailed(Account account, String folder, String message)
|
||||
{
|
||||
super.synchronizeMailboxFailed(account, folder, message);
|
||||
|
||||
|
||||
if (account.equals(mAccount) && folder.equals(mFolderName))
|
||||
{
|
||||
// Perhaps this can be restored, if done in the mHandler thread
|
||||
@ -1476,7 +1476,7 @@ public class MessageList
|
||||
}
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendPendingMessagesCompleted(Account account)
|
||||
{
|
||||
@ -1497,7 +1497,7 @@ public class MessageList
|
||||
super.sendPendingMessagesFailed(account);
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
|
||||
{
|
||||
@ -1623,12 +1623,12 @@ public class MessageList
|
||||
mUnreadMessageCount = unreadMessageCount;
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
public void pendingCommandsProcessing(Account account)
|
||||
{
|
||||
super.pendingCommandsProcessing(account);
|
||||
mHandler.refreshTitle();
|
||||
}
|
||||
public void pendingCommandsFinished(Account account)
|
||||
public void pendingCommandsFinished(Account account)
|
||||
{
|
||||
super.pendingCommandsFinished(account);
|
||||
mHandler.refreshTitle();
|
||||
@ -2312,7 +2312,7 @@ public class MessageList
|
||||
public boolean loading;
|
||||
|
||||
public boolean lastCheckFailed;
|
||||
|
||||
|
||||
public Folder folder;
|
||||
|
||||
/**
|
||||
|
@ -226,7 +226,7 @@ public class AccountSettings extends K9PreferenceActivity
|
||||
|
||||
|
||||
mLeftHanded = (CheckBoxPreference) findPreference(PREFERENCE_LEFT_HANDED);
|
||||
mLeftHanded.setChecked(mAccount.getLeftHanded());
|
||||
mLeftHanded.setChecked(mAccount.getLeftHanded());
|
||||
|
||||
mAccountHideButtons = (ListPreference) findPreference(PREFERENCE_HIDE_BUTTONS);
|
||||
mAccountHideButtons.setValue("" + mAccount.getHideMessageViewButtons());
|
||||
|
@ -130,20 +130,20 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
|
||||
SpinnerOption authTypes[] =
|
||||
{
|
||||
new SpinnerOption(0, "PLAIN" ),
|
||||
new SpinnerOption(1, "CRAM_MD5" )
|
||||
new SpinnerOption(0, "PLAIN"),
|
||||
new SpinnerOption(1, "CRAM_MD5")
|
||||
};
|
||||
|
||||
|
||||
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||
android.R.layout.simple_spinner_item, securityTypes);
|
||||
securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mSecurityTypeView.setAdapter(securityTypesAdapter);
|
||||
|
||||
ArrayAdapter<SpinnerOption> authTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||
android.R.layout.simple_spinner_item, authTypes);
|
||||
android.R.layout.simple_spinner_item, authTypes);
|
||||
authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mAuthTypeView.setAdapter(authTypesAdapter);
|
||||
|
||||
|
||||
/*
|
||||
* Updates the port when the user changes the security type. This allows
|
||||
* us to show a reasonable default which the user can change.
|
||||
@ -451,12 +451,12 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
final String userInfo;
|
||||
if (mAccountSchemes[securityType].startsWith("imap"))
|
||||
{
|
||||
String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label;
|
||||
userInfo = authType + ":" + mUsernameView.getText() + ":" + mPasswordView.getText();
|
||||
String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label;
|
||||
userInfo = authType + ":" + mUsernameView.getText() + ":" + mPasswordView.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo = mUsernameView.getText() + ":" + mPasswordView.getText();
|
||||
userInfo = mUsernameView.getText() + ":" + mPasswordView.getText();
|
||||
}
|
||||
URI uri = new URI(
|
||||
mAccountSchemes[securityType],
|
||||
|
@ -59,7 +59,7 @@ public class ImapStore extends Store
|
||||
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
|
||||
|
||||
private enum AuthType { PLAIN, CRAM_MD5 };
|
||||
|
||||
|
||||
private static final int IDLE_READ_TIMEOUT = 29 * 60 * 1000; // 29 minutes
|
||||
private static final int IDLE_REFRESH_INTERVAL = 20 * 60 * 1000; // 20 minutes
|
||||
|
||||
@ -707,7 +707,7 @@ public class ImapStore extends Store
|
||||
throw new MessagingException("ImapFolder.copyMessages passed non-ImapFolder");
|
||||
}
|
||||
|
||||
if (messages.length == 0)
|
||||
if (messages.length == 0)
|
||||
return;
|
||||
|
||||
ImapFolder iFolder = (ImapFolder)folder;
|
||||
@ -732,7 +732,7 @@ public class ImapStore extends Store
|
||||
@Override
|
||||
public void moveMessages(Message[] messages, Folder folder) throws MessagingException
|
||||
{
|
||||
if (messages.length == 0)
|
||||
if (messages.length == 0)
|
||||
return;
|
||||
copyMessages(messages, folder);
|
||||
setFlags(messages, new Flag[] { Flag.DELETED }, true);
|
||||
@ -740,7 +740,7 @@ public class ImapStore extends Store
|
||||
|
||||
public void delete(Message[] messages, String trashFolderName) throws MessagingException
|
||||
{
|
||||
if (messages.length == 0)
|
||||
if (messages.length == 0)
|
||||
return;
|
||||
|
||||
if (getName().equals(trashFolderName))
|
||||
@ -1907,13 +1907,13 @@ public class ImapStore extends Store
|
||||
|
||||
try
|
||||
{
|
||||
if ( mAuthType == AuthType.CRAM_MD5 )
|
||||
if (mAuthType == AuthType.CRAM_MD5)
|
||||
{
|
||||
authCramMD5();
|
||||
authCramMD5();
|
||||
}
|
||||
else if ( mAuthType == AuthType.PLAIN )
|
||||
else if (mAuthType == AuthType.PLAIN)
|
||||
{
|
||||
executeSimpleCommand("LOGIN \"" + escapeString(mUsername) + "\" \"" + escapeString(mPassword) + "\"", true);
|
||||
executeSimpleCommand("LOGIN \"" + escapeString(mUsername) + "\" \"" + escapeString(mPassword) + "\"", true);
|
||||
}
|
||||
authSuccess = true;
|
||||
}
|
||||
@ -2017,86 +2017,86 @@ public class ImapStore extends Store
|
||||
|
||||
protected void authCramMD5() throws AuthenticationFailedException, MessagingException
|
||||
{
|
||||
try
|
||||
{
|
||||
String tag = sendCommand("AUTHENTICATE CRAM-MD5", false);
|
||||
byte[] buf = new byte[ 1024 ];
|
||||
int b64NonceLen = 0;
|
||||
for ( int i = 0; i < buf.length; i++ )
|
||||
try
|
||||
{
|
||||
buf[ i ] = (byte)mIn.read();
|
||||
if ( buf[i] == 0x0a )
|
||||
{
|
||||
b64NonceLen = i;
|
||||
break;
|
||||
}
|
||||
String tag = sendCommand("AUTHENTICATE CRAM-MD5", false);
|
||||
byte[] buf = new byte[ 1024 ];
|
||||
int b64NonceLen = 0;
|
||||
for (int i = 0; i < buf.length; i++)
|
||||
{
|
||||
buf[ i ] = (byte)mIn.read();
|
||||
if (buf[i] == 0x0a)
|
||||
{
|
||||
b64NonceLen = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (b64NonceLen == 0)
|
||||
{
|
||||
throw new AuthenticationFailedException("Error negotiating CRAM-MD5: nonce too long.");
|
||||
}
|
||||
byte[] b64NonceTrim = new byte[ b64NonceLen - 2 ];
|
||||
System.arraycopy(buf, 1, b64NonceTrim, 0, b64NonceLen - 2);
|
||||
byte[] nonce = Base64.decodeBase64(b64NonceTrim);
|
||||
if (K9.DEBUG)
|
||||
{
|
||||
Log.d(K9.LOG_TAG, "Got nonce: " + new String(b64NonceTrim, "US-ASCII"));
|
||||
Log.d(K9.LOG_TAG, "Plaintext nonce: " + new String(nonce, "US-ASCII"));
|
||||
}
|
||||
byte[] ipad = new byte[64];
|
||||
byte[] opad = new byte[64];
|
||||
byte[] secretBytes = mPassword.getBytes("US-ASCII");
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
if (secretBytes.length > 64)
|
||||
{
|
||||
secretBytes = md.digest(secretBytes);
|
||||
}
|
||||
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
||||
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
||||
for (int i = 0; i < ipad.length; i++) ipad[i] ^= 0x36;
|
||||
for (int i = 0; i < opad.length; i++) opad[i] ^= 0x5c;
|
||||
md.update(ipad);
|
||||
byte[] firstPass = md.digest(nonce);
|
||||
md.update(opad);
|
||||
byte[] result = md.digest(firstPass);
|
||||
String plainCRAM = mUsername + " " + new String(Hex.encodeHex(result));
|
||||
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
||||
if (K9.DEBUG)
|
||||
{
|
||||
Log.d(K9.LOG_TAG, "Username == " + mUsername);
|
||||
Log.d(K9.LOG_TAG, "plainCRAM: " + plainCRAM);
|
||||
Log.d(K9.LOG_TAG, "b64CRAM: " + new String(b64CRAM, "US-ASCII"));
|
||||
}
|
||||
mOut.write(b64CRAM);
|
||||
mOut.write(new byte[] { 0x0d, 0x0a });
|
||||
mOut.flush();
|
||||
int respLen = 0;
|
||||
for (int i = 0; i < buf.length; i++)
|
||||
{
|
||||
buf[ i ] = (byte)mIn.read();
|
||||
if (buf[i] == 0x0a)
|
||||
{
|
||||
respLen = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String toMatch = tag + " OK";
|
||||
String respStr = new String(buf, 0, respLen);
|
||||
if (!respStr.startsWith(toMatch))
|
||||
{
|
||||
throw new AuthenticationFailedException("CRAM-MD5 error: " + respStr);
|
||||
}
|
||||
}
|
||||
if ( b64NonceLen == 0 )
|
||||
catch (IOException ioe)
|
||||
{
|
||||
throw new AuthenticationFailedException( "Error negotiating CRAM-MD5: nonce too long." );
|
||||
throw new AuthenticationFailedException("CRAM-MD5 Auth Failed.");
|
||||
}
|
||||
byte[] b64NonceTrim = new byte[ b64NonceLen - 2 ];
|
||||
System.arraycopy(buf, 1, b64NonceTrim, 0, b64NonceLen - 2);
|
||||
byte[] nonce = Base64.decodeBase64(b64NonceTrim);
|
||||
if ( K9.DEBUG )
|
||||
catch (NoSuchAlgorithmException nsae)
|
||||
{
|
||||
Log.d(K9.LOG_TAG, "Got nonce: " + new String( b64NonceTrim, "US-ASCII" ) );
|
||||
Log.d(K9.LOG_TAG, "Plaintext nonce: " + new String( nonce, "US-ASCII" ) );
|
||||
throw new AuthenticationFailedException("MD5 Not Available.");
|
||||
}
|
||||
byte[] ipad = new byte[64];
|
||||
byte[] opad = new byte[64];
|
||||
byte[] secretBytes = mPassword.getBytes("US-ASCII");
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
if ( secretBytes.length > 64 )
|
||||
{
|
||||
secretBytes = md.digest(secretBytes);
|
||||
}
|
||||
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
||||
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
||||
for ( int i = 0; i < ipad.length; i++ ) ipad[i] ^= 0x36;
|
||||
for ( int i = 0; i < opad.length; i++ ) opad[i] ^= 0x5c;
|
||||
md.update(ipad);
|
||||
byte[] firstPass = md.digest(nonce);
|
||||
md.update(opad);
|
||||
byte[] result = md.digest(firstPass);
|
||||
String plainCRAM = mUsername + " " + new String(Hex.encodeHex(result));
|
||||
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
||||
if ( K9.DEBUG )
|
||||
{
|
||||
Log.d(K9.LOG_TAG, "Username == " + mUsername);
|
||||
Log.d( K9.LOG_TAG, "plainCRAM: " + plainCRAM );
|
||||
Log.d( K9.LOG_TAG, "b64CRAM: " + new String(b64CRAM, "US-ASCII"));
|
||||
}
|
||||
mOut.write( b64CRAM );
|
||||
mOut.write( new byte[] { 0x0d, 0x0a } );
|
||||
mOut.flush();
|
||||
int respLen = 0;
|
||||
for ( int i = 0; i < buf.length; i++ )
|
||||
{
|
||||
buf[ i ] = (byte)mIn.read();
|
||||
if ( buf[i] == 0x0a )
|
||||
{
|
||||
respLen = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String toMatch = tag + " OK";
|
||||
String respStr = new String( buf, 0, respLen );
|
||||
if ( !respStr.startsWith( toMatch ) )
|
||||
{
|
||||
throw new AuthenticationFailedException( "CRAM-MD5 error: " + respStr );
|
||||
}
|
||||
}
|
||||
catch ( IOException ioe )
|
||||
{
|
||||
throw new AuthenticationFailedException( "CRAM-MD5 Auth Failed." );
|
||||
}
|
||||
catch ( NoSuchAlgorithmException nsae )
|
||||
{
|
||||
throw new AuthenticationFailedException( "MD5 Not Available." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void setReadTimeout(int millis) throws SocketException
|
||||
{
|
||||
mSocket.setSoTimeout(millis);
|
||||
|
@ -103,7 +103,7 @@ public class LocalStore extends Store implements Serializable
|
||||
private void doDbUpgrade(SQLiteDatabase mDb, Application application)
|
||||
{
|
||||
Log.i(K9.LOG_TAG, String.format("Upgrading database from version %d to version %d",
|
||||
mDb.getVersion(), DB_VERSION));
|
||||
mDb.getVersion(), DB_VERSION));
|
||||
|
||||
|
||||
AttachmentProvider.clear(application);
|
||||
@ -1478,7 +1478,7 @@ public class LocalStore extends Store implements Serializable
|
||||
cv.put("internal_date", message.getInternalDate() == null
|
||||
? System.currentTimeMillis() : message.getInternalDate().getTime());
|
||||
String messageId = message.getMessageId();
|
||||
if (messageId != null )
|
||||
if (messageId != null)
|
||||
{
|
||||
cv.put("message_id", messageId);
|
||||
}
|
||||
@ -2281,44 +2281,45 @@ public class LocalStore extends Store implements Serializable
|
||||
}
|
||||
|
||||
|
||||
private void loadHeaders() {
|
||||
ArrayList<LocalMessage> messages = new ArrayList<LocalMessage>();
|
||||
messages.add(this);
|
||||
mHeadersLoaded = true; // set true before calling populate headers to stop recursion
|
||||
((LocalFolder) mFolder).populateHeaders(messages);
|
||||
|
||||
}
|
||||
|
||||
public void addHeader(String name, String value)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
private void loadHeaders()
|
||||
{
|
||||
loadHeaders();
|
||||
ArrayList<LocalMessage> messages = new ArrayList<LocalMessage>();
|
||||
messages.add(this);
|
||||
mHeadersLoaded = true; // set true before calling populate headers to stop recursion
|
||||
((LocalFolder) mFolder).populateHeaders(messages);
|
||||
|
||||
}
|
||||
super.addHeader(name, value);
|
||||
}
|
||||
|
||||
public void setHeader(String name, String value)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
loadHeaders();
|
||||
super.setHeader(name, value);
|
||||
}
|
||||
public void addHeader(String name, String value)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
{
|
||||
loadHeaders();
|
||||
}
|
||||
super.addHeader(name, value);
|
||||
}
|
||||
|
||||
public String[] getHeader(String name)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
loadHeaders();
|
||||
public void setHeader(String name, String value)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
loadHeaders();
|
||||
super.setHeader(name, value);
|
||||
}
|
||||
|
||||
return super.getHeader(name);
|
||||
}
|
||||
public String[] getHeader(String name)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
loadHeaders();
|
||||
|
||||
public void removeHeader(String name)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
loadHeaders();
|
||||
super.removeHeader(name);
|
||||
}
|
||||
return super.getHeader(name);
|
||||
}
|
||||
|
||||
public void removeHeader(String name)
|
||||
{
|
||||
if (!mHeadersLoaded)
|
||||
loadHeaders();
|
||||
super.removeHeader(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -496,48 +496,48 @@ public class SmtpTransport extends Transport
|
||||
throw me;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void saslAuthCramMD5(String username, String password) throws MessagingException,
|
||||
AuthenticationFailedException, IOException
|
||||
AuthenticationFailedException, IOException
|
||||
{
|
||||
List<String> respList = executeSimpleCommand( "AUTH CRAM-MD5" );
|
||||
if ( respList.size() != 1 ) throw new AuthenticationFailedException( "Unable to negotiate CRAM-MD5" );
|
||||
String b64Nonce = respList.get(0);
|
||||
byte[] nonce = Base64.decodeBase64( b64Nonce.getBytes("US-ASCII") );
|
||||
byte[] ipad = new byte[64];
|
||||
byte[] opad = new byte[64];
|
||||
byte[] secretBytes = password.getBytes("US-ASCII");
|
||||
MessageDigest md;
|
||||
try
|
||||
{
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
}
|
||||
catch ( NoSuchAlgorithmException nsae )
|
||||
{
|
||||
throw new AuthenticationFailedException( "MD5 Not Available." );
|
||||
}
|
||||
if ( secretBytes.length > 64 )
|
||||
{
|
||||
secretBytes = md.digest(secretBytes);
|
||||
}
|
||||
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
||||
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
||||
for ( int i = 0; i < ipad.length; i++ ) ipad[i] ^= 0x36;
|
||||
for ( int i = 0; i < opad.length; i++ ) opad[i] ^= 0x5c;
|
||||
md.update(ipad);
|
||||
byte[] firstPass = md.digest(nonce);
|
||||
md.update(opad);
|
||||
byte[] result = md.digest(firstPass);
|
||||
String plainCRAM = username + " " + new String(Hex.encodeHex(result));
|
||||
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
||||
String b64CRAMString = new String( b64CRAM, "US-ASCII" );
|
||||
try
|
||||
{
|
||||
executeSimpleCommand( b64CRAMString );
|
||||
}
|
||||
catch ( MessagingException me )
|
||||
{
|
||||
throw new AuthenticationFailedException( "Unable to negotiate MD5 CRAM" );
|
||||
}
|
||||
List<String> respList = executeSimpleCommand("AUTH CRAM-MD5");
|
||||
if (respList.size() != 1) throw new AuthenticationFailedException("Unable to negotiate CRAM-MD5");
|
||||
String b64Nonce = respList.get(0);
|
||||
byte[] nonce = Base64.decodeBase64(b64Nonce.getBytes("US-ASCII"));
|
||||
byte[] ipad = new byte[64];
|
||||
byte[] opad = new byte[64];
|
||||
byte[] secretBytes = password.getBytes("US-ASCII");
|
||||
MessageDigest md;
|
||||
try
|
||||
{
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
}
|
||||
catch (NoSuchAlgorithmException nsae)
|
||||
{
|
||||
throw new AuthenticationFailedException("MD5 Not Available.");
|
||||
}
|
||||
if (secretBytes.length > 64)
|
||||
{
|
||||
secretBytes = md.digest(secretBytes);
|
||||
}
|
||||
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
||||
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
||||
for (int i = 0; i < ipad.length; i++) ipad[i] ^= 0x36;
|
||||
for (int i = 0; i < opad.length; i++) opad[i] ^= 0x5c;
|
||||
md.update(ipad);
|
||||
byte[] firstPass = md.digest(nonce);
|
||||
md.update(opad);
|
||||
byte[] result = md.digest(firstPass);
|
||||
String plainCRAM = username + " " + new String(Hex.encodeHex(result));
|
||||
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
||||
String b64CRAMString = new String(b64CRAM, "US-ASCII");
|
||||
try
|
||||
{
|
||||
executeSimpleCommand(b64CRAMString);
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
throw new AuthenticationFailedException("Unable to negotiate MD5 CRAM");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user