1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-02-17 07:30:16 -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,7 +433,8 @@ public class Account implements Serializable
}
public boolean getLeftHanded() {
public boolean getLeftHanded()
{
return mLeftHanded;
}

View File

@ -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()
);
}
}

View File

@ -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());
}
@ -3152,7 +3152,7 @@ public class MessagingController implements Runnable
}
public void getFolderUnreadMessageCount(final Account account, final String folderName,
final MessagingListener l)
final MessagingListener l)
{
Runnable unreadRunnable = new Runnable()
{

View File

@ -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)

View File

@ -23,7 +23,7 @@ public class ActivityListener extends MessagingListener
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)
{
@ -42,8 +42,8 @@ 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
@ -52,8 +52,8 @@ public class ActivityListener extends MessagingListener
}
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);
}

View File

@ -855,7 +855,7 @@ public class FolderList extends K9ListActivity
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Unable to get unreadMessageCount for " + mAccount.getDescription() + ":"
+ folder.getName());
+ folder.getName());
}
if (holder == null)

View File

@ -130,8 +130,8 @@ 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,
@ -140,7 +140,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
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);
@ -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],

View File

@ -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,84 +2017,84 @@ 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

View File

@ -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);
}

View File

@ -498,46 +498,46 @@ public class SmtpTransport extends Transport
}
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");
}
}
}