1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
Joe Steele 2014-08-18 18:12:39 -04:00
parent a659393326
commit f7fb0cca41
10 changed files with 39 additions and 45 deletions

View File

@ -1892,7 +1892,7 @@ public class Account implements BaseAccount {
public void addCertificate(CheckDirection direction, public void addCertificate(CheckDirection direction,
X509Certificate certificate) throws CertificateException { X509Certificate certificate) throws CertificateException {
Uri uri; Uri uri;
if (direction.equals(CheckDirection.INCOMING)) { if (direction == CheckDirection.INCOMING) {
uri = Uri.parse(getStoreUri()); uri = Uri.parse(getStoreUri());
} else { } else {
uri = Uri.parse(getTransportUri()); uri = Uri.parse(getTransportUri());
@ -1909,7 +1909,7 @@ public class Account implements BaseAccount {
public void deleteCertificate(String newHost, int newPort, public void deleteCertificate(String newHost, int newPort,
CheckDirection direction) { CheckDirection direction) {
Uri uri; Uri uri;
if (direction.equals(CheckDirection.INCOMING)) { if (direction == CheckDirection.INCOMING) {
uri = Uri.parse(getStoreUri()); uri = Uri.parse(getStoreUri());
} else { } else {
uri = Uri.parse(getTransportUri()); uri = Uri.parse(getTransportUri());

View File

@ -779,16 +779,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
* this account type. Also don't ask when the username is missing. * this account type. Also don't ask when the username is missing.
* Also don't ask when the AuthType is EXTERNAL. * Also don't ask when the AuthType is EXTERNAL.
*/ */
boolean configureOutgoingServer = !AuthType.EXTERNAL boolean configureOutgoingServer = AuthType.EXTERNAL != outgoing.authenticationType
.equals(outgoing.authenticationType)
&& !WebDavStore.STORE_TYPE.equals(outgoing.type) && !WebDavStore.STORE_TYPE.equals(outgoing.type)
&& outgoing.username != null && outgoing.username != null
&& !outgoing.username.isEmpty() && !outgoing.username.isEmpty()
&& (outgoing.password == null || outgoing.password && (outgoing.password == null || outgoing.password
.isEmpty()); .isEmpty());
boolean configureIncomingServer = !AuthType.EXTERNAL boolean configureIncomingServer = AuthType.EXTERNAL != incoming.authenticationType
.equals(incoming.authenticationType)
&& (incoming.password == null || incoming.password && (incoming.password == null || incoming.password
.isEmpty()); .isEmpty());

View File

@ -114,7 +114,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
ctrl.clearCertificateErrorNotifications(AccountSetupCheckSettings.this, ctrl.clearCertificateErrorNotifications(AccountSetupCheckSettings.this,
mAccount, mDirection); mAccount, mDirection);
if (mDirection.equals(CheckDirection.INCOMING)) { if (mDirection == CheckDirection.INCOMING) {
store = mAccount.getRemoteStore(); store = mAccount.getRemoteStore();
if (store instanceof WebDavStore) { if (store instanceof WebDavStore) {
@ -137,7 +137,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
finish(); finish();
return; return;
} }
if (mDirection.equals(CheckDirection.OUTGOING)) { if (mDirection == CheckDirection.OUTGOING) {
if (!(mAccount.getRemoteStore() instanceof WebDavStore)) { if (!(mAccount.getRemoteStore() instanceof WebDavStore)) {
setMessage(R.string.account_setup_check_settings_check_outgoing_msg); setMessage(R.string.account_setup_check_settings_check_outgoing_msg);
} }

View File

@ -354,7 +354,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
AuthType selection = (AuthType) mAuthTypeView.getSelectedItem(); AuthType selection = (AuthType) mAuthTypeView.getSelectedItem();
// Have the user select (or confirm) the client certificate // Have the user select (or confirm) the client certificate
if (AuthType.EXTERNAL.equals(selection)) { if (AuthType.EXTERNAL == selection) {
// This may again invoke validateFields() // This may again invoke validateFields()
mClientCertificateSpinner.chooseCertificate(); mClientCertificateSpinner.chooseCertificate();
@ -400,7 +400,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
*/ */
private void updateViewFromAuthType() { private void updateViewFromAuthType() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem(); AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType); boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
if (isAuthTypeExternal) { if (isAuthTypeExternal) {
@ -426,10 +426,10 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
*/ */
private void validateFields() { private void validateFields() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem(); AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType); boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
ConnectionSecurity connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem(); ConnectionSecurity connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
boolean hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE)); boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
if (isAuthTypeExternal && !hasConnectionSecurity) { if (isAuthTypeExternal && !hasConnectionSecurity) {
@ -459,10 +459,10 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
mPortView.addTextChangedListener(validationTextWatcher); mPortView.addTextChangedListener(validationTextWatcher);
authType = (AuthType) mAuthTypeView.getSelectedItem(); authType = (AuthType) mAuthTypeView.getSelectedItem();
isAuthTypeExternal = AuthType.EXTERNAL.equals(authType); isAuthTypeExternal = (AuthType.EXTERNAL == authType);
connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem(); connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE)); hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
} else { } else {
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition(); mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition(); mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
@ -552,7 +552,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
String password = null; String password = null;
String clientCertificateAlias = null; String clientCertificateAlias = null;
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem(); AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
if (AuthType.EXTERNAL.equals(authType)) { if (AuthType.EXTERNAL == authType) {
clientCertificateAlias = mClientCertificateSpinner.getAlias(); clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else { } else {
password = mPasswordView.getText().toString(); password = mPasswordView.getText().toString();
@ -586,7 +586,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
String clientCertificateAlias = null; String clientCertificateAlias = null;
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem(); AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
if (authType.equals(AuthType.EXTERNAL)) { if (authType == AuthType.EXTERNAL) {
clientCertificateAlias = mClientCertificateSpinner.getAlias(); clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else { } else {
password = mPasswordView.getText().toString(); password = mPasswordView.getText().toString();

View File

@ -234,8 +234,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
if (mCurrentSecurityTypeViewPosition != position) { if (mCurrentSecurityTypeViewPosition != position) {
updatePortFromSecurityType(); updatePortFromSecurityType();
boolean isInsecure = ConnectionSecurity.NONE.equals(mSecurityTypeView.getSelectedItem()); boolean isInsecure = (ConnectionSecurity.NONE == mSecurityTypeView.getSelectedItem());
boolean isAuthExternal = AuthType.EXTERNAL.equals(mAuthTypeView.getSelectedItem()); boolean isAuthExternal = (AuthType.EXTERNAL == mAuthTypeView.getSelectedItem());
boolean loginNotRequired = !mRequireLoginView.isChecked(); boolean loginNotRequired = !mRequireLoginView.isChecked();
/* /*
@ -278,7 +278,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
AuthType selection = (AuthType) mAuthTypeView.getSelectedItem(); AuthType selection = (AuthType) mAuthTypeView.getSelectedItem();
// Have the user select (or confirm) the client certificate // Have the user select (or confirm) the client certificate
if (AuthType.EXTERNAL.equals(selection)) { if (AuthType.EXTERNAL == selection) {
// This may again invoke validateFields() // This may again invoke validateFields()
mClientCertificateSpinner.chooseCertificate(); mClientCertificateSpinner.chooseCertificate();
@ -331,7 +331,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
*/ */
private void updateViewFromAuthType() { private void updateViewFromAuthType() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem(); AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType); boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
if (isAuthTypeExternal) { if (isAuthTypeExternal) {
@ -357,10 +357,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
*/ */
private void validateFields() { private void validateFields() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem(); AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType); boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
ConnectionSecurity connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem(); ConnectionSecurity connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
boolean hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE)); boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
if (isAuthTypeExternal && !hasConnectionSecurity) { if (isAuthTypeExternal && !hasConnectionSecurity) {
@ -390,10 +390,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
mPortView.addTextChangedListener(validationTextWatcher); mPortView.addTextChangedListener(validationTextWatcher);
authType = (AuthType) mAuthTypeView.getSelectedItem(); authType = (AuthType) mAuthTypeView.getSelectedItem();
isAuthTypeExternal = AuthType.EXTERNAL.equals(authType); isAuthTypeExternal = (AuthType.EXTERNAL == authType);
connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem(); connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE)); hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
} else { } else {
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition(); mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition(); mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
@ -482,7 +482,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
username = mUsernameView.getText().toString(); username = mUsernameView.getText().toString();
authType = (AuthType) mAuthTypeView.getSelectedItem(); authType = (AuthType) mAuthTypeView.getSelectedItem();
if (AuthType.EXTERNAL.equals(authType)) { if (AuthType.EXTERNAL == authType) {
clientCertificateAlias = mClientCertificateSpinner.getAlias(); clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else { } else {
password = mPasswordView.getText().toString(); password = mPasswordView.getText().toString();

View File

@ -2673,7 +2673,7 @@ public class MessagingController implements Runnable {
final NotificationManager nm = (NotificationManager) final NotificationManager nm = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE); context.getSystemService(Context.NOTIFICATION_SERVICE);
if (direction.equals(CheckDirection.INCOMING)) { if (direction == CheckDirection.INCOMING) {
nm.cancel(null, K9.CERTIFICATE_EXCEPTION_NOTIFICATION_INCOMING + account.getAccountNumber()); nm.cancel(null, K9.CERTIFICATE_EXCEPTION_NOTIFICATION_INCOMING + account.getAccountNumber());
} else { } else {
nm.cancel(null, K9.CERTIFICATE_EXCEPTION_NOTIFICATION_OUTGOING + account.getAccountNumber()); nm.cancel(null, K9.CERTIFICATE_EXCEPTION_NOTIFICATION_OUTGOING + account.getAccountNumber());

View File

@ -214,7 +214,7 @@ public class ImapStore extends Store {
authenticationType = AuthType.valueOf(userInfoParts[0]); authenticationType = AuthType.valueOf(userInfoParts[0]);
username = URLDecoder.decode(userInfoParts[1], "UTF-8"); username = URLDecoder.decode(userInfoParts[1], "UTF-8");
if (AuthType.EXTERNAL.equals(authenticationType)) { if (AuthType.EXTERNAL == authenticationType) {
clientCertificateAlias = URLDecoder.decode(userInfoParts[2], "UTF-8"); clientCertificateAlias = URLDecoder.decode(userInfoParts[2], "UTF-8");
} else { } else {
password = URLDecoder.decode(userInfoParts[2], "UTF-8"); password = URLDecoder.decode(userInfoParts[2], "UTF-8");
@ -290,7 +290,7 @@ public class ImapStore extends Store {
AuthType authType = server.authenticationType; AuthType authType = server.authenticationType;
String userInfo; String userInfo;
if (authType.equals(AuthType.EXTERNAL)) { if (authType == AuthType.EXTERNAL) {
userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc; userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc;
} else { } else {
userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc; userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;

View File

@ -128,7 +128,7 @@ public class Pop3Store extends Store {
} }
username = URLDecoder.decode(userInfoParts[userIndex], "UTF-8"); username = URLDecoder.decode(userInfoParts[userIndex], "UTF-8");
if (userInfoParts.length > passwordIndex) { if (userInfoParts.length > passwordIndex) {
if (authType.equals(AuthType.EXTERNAL)) { if (authType == AuthType.EXTERNAL) {
clientCertificateAlias = URLDecoder.decode(userInfoParts[passwordIndex], "UTF-8"); clientCertificateAlias = URLDecoder.decode(userInfoParts[passwordIndex], "UTF-8");
} else { } else {
password = URLDecoder.decode(userInfoParts[passwordIndex], "UTF-8"); password = URLDecoder.decode(userInfoParts[passwordIndex], "UTF-8");
@ -186,7 +186,7 @@ public class Pop3Store extends Store {
AuthType authType = server.authenticationType; AuthType authType = server.authenticationType;
String userInfo; String userInfo;
if (AuthType.EXTERNAL.equals(authType)) { if (AuthType.EXTERNAL == authType) {
userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc; userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc;
} else { } else {
userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc; userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;

View File

@ -105,7 +105,7 @@ public class SmtpTransport extends Transport {
// NOTE: In SmptTransport URIs, the authType comes last! // NOTE: In SmptTransport URIs, the authType comes last!
authType = AuthType.valueOf(userInfoParts[2]); authType = AuthType.valueOf(userInfoParts[2]);
username = URLDecoder.decode(userInfoParts[0], "UTF-8"); username = URLDecoder.decode(userInfoParts[0], "UTF-8");
if (authType.equals(AuthType.EXTERNAL)) { if (authType == AuthType.EXTERNAL) {
clientCertificateAlias = URLDecoder.decode(userInfoParts[1], "UTF-8"); clientCertificateAlias = URLDecoder.decode(userInfoParts[1], "UTF-8");
} else { } else {
password = URLDecoder.decode(userInfoParts[1], "UTF-8"); password = URLDecoder.decode(userInfoParts[1], "UTF-8");
@ -166,7 +166,7 @@ public class SmtpTransport extends Transport {
AuthType authType = server.authenticationType; AuthType authType = server.authenticationType;
// NOTE: authType is append at last item, in contrast to ImapStore and Pop3Store! // NOTE: authType is append at last item, in contrast to ImapStore and Pop3Store!
if (authType != null) { if (authType != null) {
if (AuthType.EXTERNAL.equals(authType)) { if (AuthType.EXTERNAL == authType) {
userInfo = userEnc + ":" + clientCertificateAliasEnc + ":" + authType.name(); userInfo = userEnc + ":" + clientCertificateAliasEnc + ":" + authType.name();
} else { } else {
userInfo = userEnc + ":" + passwordEnc + ":" + authType.name(); userInfo = userEnc + ":" + passwordEnc + ":" + authType.name();
@ -326,8 +326,7 @@ public class SmtpTransport extends Transport {
if (mUsername != null if (mUsername != null
&& mUsername.length() > 0 && mUsername.length() > 0
&& (mPassword != null && mPassword.length() > 0 || AuthType.EXTERNAL && (mPassword != null && mPassword.length() > 0 || AuthType.EXTERNAL == mAuthType)) {
.equals(mAuthType))) {
switch (mAuthType) { switch (mAuthType) {

View File

@ -381,9 +381,8 @@ public class SettingsImporter {
// Mark account as disabled if the AuthType isn't EXTERNAL and the // Mark account as disabled if the AuthType isn't EXTERNAL and the
// settings file didn't contain a password // settings file didn't contain a password
boolean createAccountDisabled = !AuthType.EXTERNAL boolean createAccountDisabled = AuthType.EXTERNAL != incoming.authenticationType &&
.equals(incoming.authenticationType) (incoming.password == null || incoming.password.isEmpty());
&& (incoming.password == null || incoming.password.isEmpty());
if (account.outgoing == null && !WebDavStore.STORE_TYPE.equals(account.incoming.type)) { if (account.outgoing == null && !WebDavStore.STORE_TYPE.equals(account.incoming.type)) {
// All account types except WebDAV need to provide outgoing server settings // All account types except WebDAV need to provide outgoing server settings
@ -403,14 +402,12 @@ public class SettingsImporter {
* outgoing servers are identical for this account type. Nor is a * outgoing servers are identical for this account type. Nor is a
* password required if the AuthType is EXTERNAL. * password required if the AuthType is EXTERNAL.
*/ */
if (!AuthType.EXTERNAL.equals(outgoing.authenticationType) boolean outgoingPasswordNeeded = AuthType.EXTERNAL != outgoing.authenticationType &&
&& !WebDavStore.STORE_TYPE.equals(outgoing.type) !WebDavStore.STORE_TYPE.equals(outgoing.type) &&
&& outgoing.username != null outgoing.username != null &&
&& !outgoing.username.isEmpty() !outgoing.username.isEmpty() &&
&& (outgoing.password == null || outgoing.password (outgoing.password == null || outgoing.password.isEmpty());
.isEmpty())) { createAccountDisabled = outgoingPasswordNeeded || createAccountDisabled;
createAccountDisabled = true;
}
} }
// Write key to mark account as disabled if necessary // Write key to mark account as disabled if necessary