1
0
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:
Jesse Vincent 2009-12-20 05:41:43 +00:00
parent 5a85446779
commit 3914a78b53
13 changed files with 270 additions and 268 deletions

View File

@ -433,11 +433,12 @@ public class Account implements Serializable
} }
public boolean getLeftHanded() { public boolean getLeftHanded()
{
return mLeftHanded; return mLeftHanded;
} }
public void setLeftHanded(boolean leftie) public void setLeftHanded(boolean leftie)
{ {
mLeftHanded = leftie; mLeftHanded = leftie;
} }

View File

@ -524,19 +524,19 @@ public class K9 extends Application
intent.putExtra(K9.Intents.EmailReceived.EXTRA_FROM_SELF, account.isAnIdentity(message.getFrom())); intent.putExtra(K9.Intents.EmailReceived.EXTRA_FROM_SELF, account.isAnIdentity(message.getFrom()));
K9.this.sendBroadcast(intent); K9.this.sendBroadcast(intent);
Log.d(K9.LOG_TAG, "Broadcasted: action=" + action Log.d(K9.LOG_TAG, "Broadcasted: action=" + action
+ " account=" + account.getDescription() + " account=" + account.getDescription()
+ " folder=" + folder + " folder=" + folder
+ " message uid=" + message.getUid() + " message uid=" + message.getUid()
); );
} }
catch (MessagingException e) catch (MessagingException e)
{ {
Log.w(K9.LOG_TAG, "Error: action=" + action Log.w(K9.LOG_TAG, "Error: action=" + action
+ " account=" + account.getDescription() + " account=" + account.getDescription()
+ " folder=" + folder + " folder=" + folder
+ " message uid=" + message.getUid() + " message uid=" + message.getUid()
); );
} }
} }
@ -557,7 +557,7 @@ public class K9 extends Application
{ {
broadcastIntent(K9.Intents.EmailReceived.ACTION_EMAIL_RECEIVED, account, folder, message); broadcastIntent(K9.Intents.EmailReceived.ACTION_EMAIL_RECEIVED, account, folder, message);
} }
}); });

View File

@ -739,7 +739,7 @@ public class MessagingController implements Runnable
if (K9.DEBUG) if (K9.DEBUG)
{ {
Log.d(K9.LOG_TAG, "SYNC: About to process pending commands for account " + Log.d(K9.LOG_TAG, "SYNC: About to process pending commands for account " +
account.getDescription() ); account.getDescription());
} }
try try
{ {
@ -933,8 +933,8 @@ public class MessagingController implements Runnable
if (K9.DEBUG) if (K9.DEBUG)
{ {
Log.d(K9.LOG_TAG, "Done synchronizing folder " + Log.d(K9.LOG_TAG, "Done synchronizing folder " +
account.getDescription() + ":" + folder + " @ " + new Date() + account.getDescription() + ":" + folder + " @ " + new Date() +
" with " + newMessages + " new messages"); " with " + newMessages + " new messages");
} }
for (MessagingListener l : getListeners()) for (MessagingListener l : getListeners())
@ -1002,7 +1002,7 @@ public class MessagingController implements Runnable
} }
addErrorMessage(account, e); addErrorMessage(account, e);
Log.e(K9.LOG_TAG, "Failed synchronizing folder " + 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 AtomicInteger progress = new AtomicInteger(0);
final int todo = unsyncedMessages.size() + syncFlagMessages.size(); final int todo = unsyncedMessages.size() + syncFlagMessages.size();
for (MessagingListener l : getListeners()) for (MessagingListener l : getListeners())
@ -1550,27 +1550,27 @@ public class MessagingController implements Runnable
} }
}); });
} }
private void processPendingCommandsSynchronous(Account account) throws MessagingException private void processPendingCommandsSynchronous(Account account) throws MessagingException
{ {
LocalStore localStore = (LocalStore) Store.getInstance( LocalStore localStore = (LocalStore) Store.getInstance(
account.getLocalStoreUri(), account.getLocalStoreUri(),
mApplication); mApplication);
ArrayList<PendingCommand> commands = localStore.getPendingCommands(); ArrayList<PendingCommand> commands = localStore.getPendingCommands();
int progress = 0; int progress = 0;
int todo = commands.size(); int todo = commands.size();
if (todo == 0) if (todo == 0)
{ {
return; return;
} }
for (MessagingListener l : getListeners()) for (MessagingListener l : getListeners())
{ {
l.pendingCommandsProcessing(account); l.pendingCommandsProcessing(account);
l.synchronizeMailboxProgress(account, null, progress, todo); l.synchronizeMailboxProgress(account, null, progress, todo);
} }
PendingCommand processingCommand = null; PendingCommand processingCommand = null;
try try
{ {
@ -3150,9 +3150,9 @@ public class MessagingController implements Runnable
put("getAccountUnread:" + account.getDescription(), l, unreadRunnable); put("getAccountUnread:" + account.getDescription(), l, unreadRunnable);
} }
public void getFolderUnreadMessageCount(final Account account, final String folderName, public void getFolderUnreadMessageCount(final Account account, final String folderName,
final MessagingListener l) final MessagingListener l)
{ {
Runnable unreadRunnable = new Runnable() Runnable unreadRunnable = new Runnable()
{ {
@ -4323,7 +4323,7 @@ public class MessagingController implements Runnable
int syncingTotalMessagesInMailbox; int syncingTotalMessagesInMailbox;
int syncingNumNewMessages; int syncingNumNewMessages;
int folderCompleted = 0; int folderCompleted = 0;
int folderTotal = 0; int folderTotal = 0;
String processingCommandTitle = null; String processingCommandTitle = null;
@ -4473,7 +4473,7 @@ public class MessagingController implements Runnable
if (processingStarted.processingCommandTitle != null) if (processingStarted.processingCommandTitle != null)
{ {
other.pendingCommandStarted(processingStarted.account, processingStarted.processingCommandTitle); other.pendingCommandStarted(processingStarted.account, processingStarted.processingCommandTitle);
} }
else else
{ {
@ -4514,8 +4514,8 @@ public class MessagingController implements Runnable
Memory memory = getMemory(account, null); Memory memory = getMemory(account, null);
memory.sendingState = MemorizingState.FAILED; memory.sendingState = MemorizingState.FAILED;
} }
public void synchronizeMailboxProgress(Account account, String folderName, int completed, int total) public void synchronizeMailboxProgress(Account account, String folderName, int completed, int total)
{ {
Memory memory = getMemory(account, folderName); Memory memory = getMemory(account, folderName);
@ -4523,15 +4523,15 @@ public class MessagingController implements Runnable
memory.folderTotal = total; memory.folderTotal = total;
} }
public void pendingCommandsProcessing(Account account) public void pendingCommandsProcessing(Account account)
{ {
Memory memory = getMemory(account, null); Memory memory = getMemory(account, null);
memory.processingState = MemorizingState.STARTED; memory.processingState = MemorizingState.STARTED;
memory.folderCompleted = 0; memory.folderCompleted = 0;
memory.folderTotal = 0; memory.folderTotal = 0;
} }
public void pendingCommandsFinished(Account account) public void pendingCommandsFinished(Account account)
{ {
Memory memory = getMemory(account, null); Memory memory = getMemory(account, null);
memory.processingState = MemorizingState.FINISHED; memory.processingState = MemorizingState.FINISHED;
@ -4541,7 +4541,7 @@ public class MessagingController implements Runnable
Memory memory = getMemory(account, null); Memory memory = getMemory(account, null);
memory.processingCommandTitle = commandTitle; memory.processingCommandTitle = commandTitle;
} }
public void pendingCommandCompleted(Account account, String commandTitle) public void pendingCommandCompleted(Account account, String commandTitle)
{ {
Memory memory = getMemory(account, null); Memory memory = getMemory(account, null);

View File

@ -73,7 +73,7 @@ public class MessagingListener
public void synchronizeMailboxStarted(Account account, String folder) public void synchronizeMailboxStarted(Account account, String folder)
{ {
} }
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) 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, int unreadMessageCount)
{ {
} }
public void folderStatusChanged(Account account, String folderName) public void folderStatusChanged(Account account, String folderName)
{ {
} }
@ -197,12 +197,12 @@ public class MessagingListener
String reason) String reason)
{ {
} }
public void pendingCommandsProcessing(Account account) {} public void pendingCommandsProcessing(Account account) {}
public void pendingCommandsFinished(Account account) {} public void pendingCommandsFinished(Account account) {}
public void pendingCommandStarted(Account account, String commandTitle) public void pendingCommandStarted(Account account, String commandTitle)
{} {}
public void pendingCommandCompleted(Account account, String commandTitle) public void pendingCommandCompleted(Account account, String commandTitle)
{} {}

View File

@ -36,7 +36,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
private Account mSelectedContextAccount; private Account mSelectedContextAccount;
private int mUnreadMessageCount = 0; private int mUnreadMessageCount = 0;
private AccountsHandler mHandler = new AccountsHandler(); private AccountsHandler mHandler = new AccountsHandler();
private AccountsAdapter mAdapter; private AccountsAdapter mAdapter;
@ -109,7 +109,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
private void setViewTitle() private void setViewTitle()
{ {
String dispString = mListener.formatHeader(Accounts.this, getString(R.string.accounts_title), mUnreadMessageCount); String dispString = mListener.formatHeader(Accounts.this, getString(R.string.accounts_title), mUnreadMessageCount);
setTitle(dispString); setTitle(dispString);
} }
public void refreshTitle() public void refreshTitle()
@ -211,7 +211,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener); MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener);
mHandler.progress(false); mHandler.progress(false);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
@ -222,7 +222,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
mHandler.progress(true); mHandler.progress(true);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
{ {
super.synchronizeMailboxProgress(account, folder, completed, total); super.synchronizeMailboxProgress(account, folder, completed, total);
@ -238,14 +238,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
@Override @Override
public void sendPendingMessagesStarted(Account account) public void sendPendingMessagesStarted(Account account)
{ {
super.sendPendingMessagesStarted(account); super.sendPendingMessagesStarted(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
@Override @Override
public void sendPendingMessagesCompleted(Account account) public void sendPendingMessagesCompleted(Account account)
{ {
@ -253,7 +253,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
@Override @Override
public void sendPendingMessagesFailed(Account account) public void sendPendingMessagesFailed(Account account)
{ {
@ -261,12 +261,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
public void pendingCommandsProcessing(Account account) public void pendingCommandsProcessing(Account account)
{ {
super.pendingCommandsProcessing(account); super.pendingCommandsProcessing(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
public void pendingCommandsFinished(Account account) public void pendingCommandsFinished(Account account)
{ {
super.pendingCommandsFinished(account); super.pendingCommandsFinished(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
@ -282,7 +282,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
}; };
private static String UNREAD_MESSAGE_COUNTS = "unreadMessageCounts"; 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) private void onOpenAccount(Account account, boolean startup)
{ {
if (K9.FOLDER_NONE.equals(account.getAutoExpandFolderName())) if (K9.FOLDER_NONE.equals(account.getAutoExpandFolderName()))
{ {
FolderList.actionHandleAccount(this, account, startup); FolderList.actionHandleAccount(this, account, startup);
} }
else else
{ {
MessageList.actionHandleFolder(this, account, account.getAutoExpandFolderName(), startup); MessageList.actionHandleFolder(this, account, account.getAutoExpandFolderName(), startup);
} }
} }
public void onClick(View view) public void onClick(View view)

View File

@ -16,15 +16,15 @@ public class ActivityListener extends MessagingListener
private int mFolderTotal = 0; private int mFolderTotal = 0;
private String mProcessingAccountDescription = null; private String mProcessingAccountDescription = null;
private String mProcessingCommandTitle = null; private String mProcessingCommandTitle = null;
public String formatHeader(Context context, String activityPrefix, int unreadMessageCount) public String formatHeader(Context context, String activityPrefix, int unreadMessageCount)
{ {
String operation = null; String operation = null;
String progress = null; String progress = null;
if (mLoadingAccountDescription != null || mSendingAccountDescription != null || mProcessingAccountDescription != 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) if (mLoadingFolderName != null)
{ {
String displayName = mLoadingFolderName; String displayName = mLoadingFolderName;
@ -34,7 +34,7 @@ public class ActivityListener extends MessagingListener
} }
operation = context.getString(R.string.status_loading_account_folder, mLoadingAccountDescription, displayName, progress); operation = context.getString(R.string.status_loading_account_folder, mLoadingAccountDescription, displayName, progress);
} }
else if (mSendingAccountDescription != null) else if (mSendingAccountDescription != null)
{ {
operation = context.getString(R.string.status_sending_account, mSendingAccountDescription, progress); operation = context.getString(R.string.status_sending_account, mSendingAccountDescription, progress);
@ -42,22 +42,22 @@ public class ActivityListener extends MessagingListener
else if (mProcessingAccountDescription != null) else if (mProcessingAccountDescription != null)
{ {
operation = context.getString(R.string.status_processing_account, mProcessingAccountDescription, operation = context.getString(R.string.status_processing_account, mProcessingAccountDescription,
mProcessingCommandTitle != null ? mProcessingCommandTitle : "", mProcessingCommandTitle != null ? mProcessingCommandTitle : "",
progress); progress);
} }
} }
else else
{ {
operation = ""; operation = "";
} }
return context.getString(R.string.activity_header_format, activityPrefix, return context.getString(R.string.activity_header_format, activityPrefix,
(unreadMessageCount > 0 ? context.getString(R.string.activity_unread_count, unreadMessageCount) : ""), (unreadMessageCount > 0 ? context.getString(R.string.activity_unread_count, unreadMessageCount) : ""),
operation); operation);
} }
@Override @Override
public void synchronizeMailboxFinished( public void synchronizeMailboxFinished(
Account account, Account account,
@ -77,7 +77,7 @@ public class ActivityListener extends MessagingListener
mFolderCompleted = 0; mFolderCompleted = 0;
mFolderTotal = 0; mFolderTotal = 0;
} }
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
{ {
mFolderCompleted = completed; mFolderCompleted = completed;
@ -92,32 +92,32 @@ public class ActivityListener extends MessagingListener
mLoadingFolderName = null; mLoadingFolderName = null;
} }
@Override @Override
public void sendPendingMessagesStarted(Account account) public void sendPendingMessagesStarted(Account account)
{ {
mSendingAccountDescription = account.getDescription(); mSendingAccountDescription = account.getDescription();
} }
@Override @Override
public void sendPendingMessagesCompleted(Account account) public void sendPendingMessagesCompleted(Account account)
{ {
mSendingAccountDescription = null; mSendingAccountDescription = null;
} }
@Override @Override
public void sendPendingMessagesFailed(Account account) public void sendPendingMessagesFailed(Account account)
{ {
mSendingAccountDescription = null; mSendingAccountDescription = null;
} }
public void pendingCommandsProcessing(Account account) public void pendingCommandsProcessing(Account account)
{ {
mProcessingAccountDescription = account.getDescription(); mProcessingAccountDescription = account.getDescription();
mFolderCompleted = 0; mFolderCompleted = 0;
mFolderTotal = 0; mFolderTotal = 0;
} }
public void pendingCommandsFinished(Account account) public void pendingCommandsFinished(Account account)
{ {
mProcessingAccountDescription = null; mProcessingAccountDescription = null;
} }
@ -125,7 +125,7 @@ public class ActivityListener extends MessagingListener
{ {
mProcessingCommandTitle = commandTitle; mProcessingCommandTitle = commandTitle;
} }
public void pendingCommandCompleted(Account account, String commandTitle) public void pendingCommandCompleted(Account account, String commandTitle)
{ {
mProcessingCommandTitle = null; mProcessingCommandTitle = null;

View File

@ -63,9 +63,9 @@ public class FolderList extends K9ListActivity
private FolderListHandler mHandler = new FolderListHandler(); private FolderListHandler mHandler = new FolderListHandler();
private boolean mStartup = false; private boolean mStartup = false;
private int mUnreadMessageCount = 0; private int mUnreadMessageCount = 0;
class FolderListHandler extends Handler class FolderListHandler extends Handler
{ {
@ -141,10 +141,10 @@ public class FolderList extends K9ListActivity
private void setViewTitle() private void setViewTitle()
{ {
String dispString = mAdapter.mListener.formatHeader(FolderList.this, getString(R.string.folder_list_title, mAccount.getDescription()), mUnreadMessageCount); String dispString = mAdapter.mListener.formatHeader(FolderList.this, getString(R.string.folder_list_title, mAccount.getDescription()), mUnreadMessageCount);
setTitle(dispString); setTitle(dispString);
setTitle(dispString); setTitle(dispString);
} }
@ -320,7 +320,7 @@ public class FolderList extends K9ListActivity
savedFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER); savedFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER);
} }
if (mStartup if (mStartup
&& initialFolder != null && initialFolder != null
&& !K9.FOLDER_NONE.equals(initialFolder)) && !K9.FOLDER_NONE.equals(initialFolder))
{ {
@ -397,7 +397,7 @@ public class FolderList extends K9ListActivity
MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener); MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
mAccount.refresh(Preferences.getPreferences(this)); mAccount.refresh(Preferences.getPreferences(this));
MessagingController.getInstance(getApplication()).getAccountUnreadCount(this, mAccount, mAdapter.mListener); MessagingController.getInstance(getApplication()).getAccountUnreadCount(this, mAccount, mAdapter.mListener);
onRefresh(!REFRESH_REMOTE); onRefresh(!REFRESH_REMOTE);
NotificationManager notifMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager notifMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
@ -854,8 +854,8 @@ public class FolderList extends K9ListActivity
} }
catch (Exception e) catch (Exception e)
{ {
Log.e(K9.LOG_TAG, "Unable to get unreadMessageCount for " + mAccount.getDescription() + ":" Log.e(K9.LOG_TAG, "Unable to get unreadMessageCount for " + mAccount.getDescription() + ":"
+ folder.getName()); + folder.getName());
} }
if (holder == null) if (holder == null)
@ -888,9 +888,9 @@ public class FolderList extends K9ListActivity
mHandler.progress(true); mHandler.progress(true);
mHandler.folderLoading(folder, true); mHandler.folderLoading(folder, true);
mHandler.dataChanged(); mHandler.dataChanged();
} }
@Override @Override
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
{ {
@ -903,7 +903,7 @@ public class FolderList extends K9ListActivity
} }
mHandler.dataChanged(); mHandler.dataChanged();
} }
@Override @Override
public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages) public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages)
{ {
@ -917,7 +917,7 @@ public class FolderList extends K9ListActivity
mHandler.folderLoading(folder, false); mHandler.folderLoading(folder, false);
refreshFolder(account, folder); refreshFolder(account, folder);
} }
@ -975,7 +975,7 @@ public class FolderList extends K9ListActivity
} }
mHandler.dataChanged(); mHandler.dataChanged();
} }
@Override @Override
@ -1035,7 +1035,7 @@ public class FolderList extends K9ListActivity
} }
refreshFolder(account, mAccount.getOutboxFolderName()); refreshFolder(account, mAccount.getOutboxFolderName());
} }
@ -1044,7 +1044,7 @@ public class FolderList extends K9ListActivity
{ {
super.sendPendingMessagesStarted(account); super.sendPendingMessagesStarted(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
if (!account.equals(mAccount)) if (!account.equals(mAccount))
{ {
return; return;
@ -1078,12 +1078,12 @@ public class FolderList extends K9ListActivity
mHandler.accountSizeChanged(oldSize, newSize); mHandler.accountSizeChanged(oldSize, newSize);
} }
public void pendingCommandsProcessing(Account account) public void pendingCommandsProcessing(Account account)
{ {
super.pendingCommandsProcessing(account); super.pendingCommandsProcessing(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
public void pendingCommandsFinished(Account account) public void pendingCommandsFinished(Account account)
{ {
super.pendingCommandsFinished(account); super.pendingCommandsFinished(account);
mHandler.refreshTitle(); mHandler.refreshTitle();

View File

@ -107,7 +107,7 @@ public class MessageList
private Account mAccount; private Account mAccount;
private int mUnreadMessageCount = 0; private int mUnreadMessageCount = 0;
/** /**
* Stores the name of the folder that we want to open as soon as possible * 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); 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); String dispString = mAdapter.mListener.formatHeader(MessageList.this, getString(R.string.message_list_title, mAccount.getDescription(), displayName), mUnreadMessageCount);
setTitle(dispString); setTitle(dispString);
int level = Window.PROGRESS_END; int level = Window.PROGRESS_END;
if (mCurrentFolder.loading && mAdapter.mListener.getFolderTotal() > 0) if (mCurrentFolder.loading && mAdapter.mListener.getFolderTotal() > 0)
@ -242,7 +242,7 @@ public class MessageList
level = Window.PROGRESS_END; level = Window.PROGRESS_END;
} }
} }
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, level); 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()); notifMgr.cancel(-1000 - mAccount.getAccountNumber());
controller.getFolderUnreadMessageCount(mAccount, mFolderName, mAdapter.mListener); controller.getFolderUnreadMessageCount(mAccount, mFolderName, mAdapter.mListener);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
@Override @Override
@ -1435,7 +1435,7 @@ public class MessageList
public void synchronizeMailboxStarted(Account account, String folder) public void synchronizeMailboxStarted(Account account, String folder)
{ {
super.synchronizeMailboxStarted(account, folder); super.synchronizeMailboxStarted(account, folder);
if (account.equals(mAccount) && folder.equals(mFolderName)) if (account.equals(mAccount) && folder.equals(mFolderName))
{ {
mHandler.progress(true); mHandler.progress(true);
@ -1451,7 +1451,7 @@ public class MessageList
int totalMessagesInMailbox, int numNewMessages) int totalMessagesInMailbox, int numNewMessages)
{ {
super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages); super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages);
if (account.equals(mAccount) && folder.equals(mFolderName)) if (account.equals(mAccount) && folder.equals(mFolderName))
{ {
mHandler.progress(false); mHandler.progress(false);
@ -1465,7 +1465,7 @@ public class MessageList
public void synchronizeMailboxFailed(Account account, String folder, String message) public void synchronizeMailboxFailed(Account account, String folder, String message)
{ {
super.synchronizeMailboxFailed(account, folder, message); super.synchronizeMailboxFailed(account, folder, message);
if (account.equals(mAccount) && folder.equals(mFolderName)) if (account.equals(mAccount) && folder.equals(mFolderName))
{ {
// Perhaps this can be restored, if done in the mHandler thread // Perhaps this can be restored, if done in the mHandler thread
@ -1476,7 +1476,7 @@ public class MessageList
} }
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
@Override @Override
public void sendPendingMessagesCompleted(Account account) public void sendPendingMessagesCompleted(Account account)
{ {
@ -1497,7 +1497,7 @@ public class MessageList
super.sendPendingMessagesFailed(account); super.sendPendingMessagesFailed(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
@Override @Override
public void synchronizeMailboxProgress(Account account, String folder, int completed, int total) public void synchronizeMailboxProgress(Account account, String folder, int completed, int total)
{ {
@ -1623,12 +1623,12 @@ public class MessageList
mUnreadMessageCount = unreadMessageCount; mUnreadMessageCount = unreadMessageCount;
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
public void pendingCommandsProcessing(Account account) public void pendingCommandsProcessing(Account account)
{ {
super.pendingCommandsProcessing(account); super.pendingCommandsProcessing(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
} }
public void pendingCommandsFinished(Account account) public void pendingCommandsFinished(Account account)
{ {
super.pendingCommandsFinished(account); super.pendingCommandsFinished(account);
mHandler.refreshTitle(); mHandler.refreshTitle();
@ -2312,7 +2312,7 @@ public class MessageList
public boolean loading; public boolean loading;
public boolean lastCheckFailed; public boolean lastCheckFailed;
public Folder folder; public Folder folder;
/** /**

View File

@ -226,7 +226,7 @@ public class AccountSettings extends K9PreferenceActivity
mLeftHanded = (CheckBoxPreference) findPreference(PREFERENCE_LEFT_HANDED); mLeftHanded = (CheckBoxPreference) findPreference(PREFERENCE_LEFT_HANDED);
mLeftHanded.setChecked(mAccount.getLeftHanded()); mLeftHanded.setChecked(mAccount.getLeftHanded());
mAccountHideButtons = (ListPreference) findPreference(PREFERENCE_HIDE_BUTTONS); mAccountHideButtons = (ListPreference) findPreference(PREFERENCE_HIDE_BUTTONS);
mAccountHideButtons.setValue("" + mAccount.getHideMessageViewButtons()); mAccountHideButtons.setValue("" + mAccount.getHideMessageViewButtons());

View File

@ -130,20 +130,20 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
SpinnerOption authTypes[] = SpinnerOption authTypes[] =
{ {
new SpinnerOption(0, "PLAIN" ), new SpinnerOption(0, "PLAIN"),
new SpinnerOption(1, "CRAM_MD5" ) new SpinnerOption(1, "CRAM_MD5")
}; };
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this, ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
android.R.layout.simple_spinner_item, securityTypes); android.R.layout.simple_spinner_item, securityTypes);
securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSecurityTypeView.setAdapter(securityTypesAdapter); mSecurityTypeView.setAdapter(securityTypesAdapter);
ArrayAdapter<SpinnerOption> authTypesAdapter = new ArrayAdapter<SpinnerOption>(this, 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); authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mAuthTypeView.setAdapter(authTypesAdapter); mAuthTypeView.setAdapter(authTypesAdapter);
/* /*
* Updates the port when the user changes the security type. This allows * Updates the port when the user changes the security type. This allows
* us to show a reasonable default which the user can change. * 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; final String userInfo;
if (mAccountSchemes[securityType].startsWith("imap")) if (mAccountSchemes[securityType].startsWith("imap"))
{ {
String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label; String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label;
userInfo = authType + ":" + mUsernameView.getText() + ":" + mPasswordView.getText(); userInfo = authType + ":" + mUsernameView.getText() + ":" + mPasswordView.getText();
} }
else else
{ {
userInfo = mUsernameView.getText() + ":" + mPasswordView.getText(); userInfo = mUsernameView.getText() + ":" + mPasswordView.getText();
} }
URI uri = new URI( URI uri = new URI(
mAccountSchemes[securityType], mAccountSchemes[securityType],

View File

@ -59,7 +59,7 @@ public class ImapStore extends Store
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4; public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
private enum AuthType { PLAIN, CRAM_MD5 }; private enum AuthType { PLAIN, CRAM_MD5 };
private static final int IDLE_READ_TIMEOUT = 29 * 60 * 1000; // 29 minutes private static final int IDLE_READ_TIMEOUT = 29 * 60 * 1000; // 29 minutes
private static final int IDLE_REFRESH_INTERVAL = 20 * 60 * 1000; // 20 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"); throw new MessagingException("ImapFolder.copyMessages passed non-ImapFolder");
} }
if (messages.length == 0) if (messages.length == 0)
return; return;
ImapFolder iFolder = (ImapFolder)folder; ImapFolder iFolder = (ImapFolder)folder;
@ -732,7 +732,7 @@ public class ImapStore extends Store
@Override @Override
public void moveMessages(Message[] messages, Folder folder) throws MessagingException public void moveMessages(Message[] messages, Folder folder) throws MessagingException
{ {
if (messages.length == 0) if (messages.length == 0)
return; return;
copyMessages(messages, folder); copyMessages(messages, folder);
setFlags(messages, new Flag[] { Flag.DELETED }, true); 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 public void delete(Message[] messages, String trashFolderName) throws MessagingException
{ {
if (messages.length == 0) if (messages.length == 0)
return; return;
if (getName().equals(trashFolderName)) if (getName().equals(trashFolderName))
@ -1907,13 +1907,13 @@ public class ImapStore extends Store
try 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; authSuccess = true;
} }
@ -2017,86 +2017,86 @@ public class ImapStore extends Store
protected void authCramMD5() throws AuthenticationFailedException, MessagingException protected void authCramMD5() throws AuthenticationFailedException, MessagingException
{ {
try try
{
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(); String tag = sendCommand("AUTHENTICATE CRAM-MD5", false);
if ( buf[i] == 0x0a ) byte[] buf = new byte[ 1024 ];
{ int b64NonceLen = 0;
b64NonceLen = i; for (int i = 0; i < buf.length; i++)
break; {
} 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 ]; catch (NoSuchAlgorithmException nsae)
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" ) ); throw new AuthenticationFailedException("MD5 Not Available.");
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 );
}
}
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 protected void setReadTimeout(int millis) throws SocketException
{ {
mSocket.setSoTimeout(millis); mSocket.setSoTimeout(millis);

View File

@ -103,7 +103,7 @@ public class LocalStore extends Store implements Serializable
private void doDbUpgrade(SQLiteDatabase mDb, Application application) private void doDbUpgrade(SQLiteDatabase mDb, Application application)
{ {
Log.i(K9.LOG_TAG, String.format("Upgrading database from version %d to version %d", 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); AttachmentProvider.clear(application);
@ -1478,7 +1478,7 @@ public class LocalStore extends Store implements Serializable
cv.put("internal_date", message.getInternalDate() == null cv.put("internal_date", message.getInternalDate() == null
? System.currentTimeMillis() : message.getInternalDate().getTime()); ? System.currentTimeMillis() : message.getInternalDate().getTime());
String messageId = message.getMessageId(); String messageId = message.getMessageId();
if (messageId != null ) if (messageId != null)
{ {
cv.put("message_id", messageId); cv.put("message_id", messageId);
} }
@ -2281,44 +2281,45 @@ public class LocalStore extends Store implements Serializable
} }
private void loadHeaders() { 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)
{ {
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) public void addHeader(String name, String value)
{ {
if (!mHeadersLoaded) if (!mHeadersLoaded)
loadHeaders(); {
super.setHeader(name, value); loadHeaders();
} }
super.addHeader(name, value);
}
public String[] getHeader(String name) public void setHeader(String name, String value)
{ {
if (!mHeadersLoaded) if (!mHeadersLoaded)
loadHeaders(); loadHeaders();
super.setHeader(name, value);
}
return super.getHeader(name); public String[] getHeader(String name)
} {
if (!mHeadersLoaded)
loadHeaders();
public void removeHeader(String name) return super.getHeader(name);
{ }
if (!mHeadersLoaded)
loadHeaders(); public void removeHeader(String name)
super.removeHeader(name); {
} if (!mHeadersLoaded)
loadHeaders();
super.removeHeader(name);
}

View File

@ -496,48 +496,48 @@ public class SmtpTransport extends Transport
throw me; throw me;
} }
} }
private void saslAuthCramMD5(String username, String password) throws MessagingException, private void saslAuthCramMD5(String username, String password) throws MessagingException,
AuthenticationFailedException, IOException AuthenticationFailedException, IOException
{ {
List<String> respList = executeSimpleCommand( "AUTH CRAM-MD5" ); List<String> respList = executeSimpleCommand("AUTH CRAM-MD5");
if ( respList.size() != 1 ) throw new AuthenticationFailedException( "Unable to negotiate CRAM-MD5" ); if (respList.size() != 1) throw new AuthenticationFailedException("Unable to negotiate CRAM-MD5");
String b64Nonce = respList.get(0); String b64Nonce = respList.get(0);
byte[] nonce = Base64.decodeBase64( b64Nonce.getBytes("US-ASCII") ); byte[] nonce = Base64.decodeBase64(b64Nonce.getBytes("US-ASCII"));
byte[] ipad = new byte[64]; byte[] ipad = new byte[64];
byte[] opad = new byte[64]; byte[] opad = new byte[64];
byte[] secretBytes = password.getBytes("US-ASCII"); byte[] secretBytes = password.getBytes("US-ASCII");
MessageDigest md; MessageDigest md;
try try
{ {
md = MessageDigest.getInstance("MD5"); md = MessageDigest.getInstance("MD5");
} }
catch ( NoSuchAlgorithmException nsae ) catch (NoSuchAlgorithmException nsae)
{ {
throw new AuthenticationFailedException( "MD5 Not Available." ); throw new AuthenticationFailedException("MD5 Not Available.");
} }
if ( secretBytes.length > 64 ) if (secretBytes.length > 64)
{ {
secretBytes = md.digest(secretBytes); secretBytes = md.digest(secretBytes);
} }
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length); System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
System.arraycopy(secretBytes, 0, opad, 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 < ipad.length; i++) ipad[i] ^= 0x36;
for ( int i = 0; i < opad.length; i++ ) opad[i] ^= 0x5c; for (int i = 0; i < opad.length; i++) opad[i] ^= 0x5c;
md.update(ipad); md.update(ipad);
byte[] firstPass = md.digest(nonce); byte[] firstPass = md.digest(nonce);
md.update(opad); md.update(opad);
byte[] result = md.digest(firstPass); byte[] result = md.digest(firstPass);
String plainCRAM = username + " " + new String(Hex.encodeHex(result)); String plainCRAM = username + " " + new String(Hex.encodeHex(result));
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII")); byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
String b64CRAMString = new String( b64CRAM, "US-ASCII" ); String b64CRAMString = new String(b64CRAM, "US-ASCII");
try try
{ {
executeSimpleCommand( b64CRAMString ); executeSimpleCommand(b64CRAMString);
} }
catch ( MessagingException me ) catch (MessagingException me)
{ {
throw new AuthenticationFailedException( "Unable to negotiate MD5 CRAM" ); throw new AuthenticationFailedException("Unable to negotiate MD5 CRAM");
} }
} }
} }