mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Use localized strings for authentication type
AUTOMATIC = "Automatic" PLAIN = "Normal password" CRAM_MD5 = "Encrypted password" SMTP also uses LOGIN. No localized text was associated with that because a future commit will remove that option. (The text is similar to that of Thunderbird's)
This commit is contained in:
parent
f24ac67e4d
commit
dc9720ca13
@ -385,6 +385,10 @@ Please submit bug reports, contribute new features and ask questions at
|
||||
<string name="account_setup_account_type_imap_action">IMAP</string>
|
||||
<string name="account_setup_account_type_webdav_action">Exchange (WebDAV)</string>
|
||||
|
||||
<string name="account_setup_auth_type_automatic">Automatic</string>
|
||||
<string name="account_setup_auth_type_normal_password">Normal password</string>
|
||||
<string name="account_setup_auth_type_encrypted_password">Encrypted password</string>
|
||||
|
||||
<string name="account_setup_incoming_title">Incoming server settings</string>
|
||||
<string name="account_setup_incoming_username_label">Username</string>
|
||||
<string name="account_setup_incoming_password_label">Password</string>
|
||||
|
@ -18,6 +18,7 @@ import com.fsck.k9.*;
|
||||
import com.fsck.k9.activity.K9Activity;
|
||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
import com.fsck.k9.mail.ServerSettings;
|
||||
import com.fsck.k9.mail.Store;
|
||||
@ -58,11 +59,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
ConnectionSecurity.STARTTLS_REQUIRED
|
||||
};
|
||||
|
||||
private static final String[] AUTH_TYPES = {
|
||||
"PLAIN", "CRAM_MD5"
|
||||
};
|
||||
|
||||
|
||||
private int[] mAccountPorts;
|
||||
private String mStoreType;
|
||||
private EditText mUsernameView;
|
||||
@ -83,6 +79,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
private CheckBox mCompressionWifi;
|
||||
private CheckBox mCompressionOther;
|
||||
private CheckBox mSubscribedFoldersOnly;
|
||||
private ArrayAdapter<AuthType> mAuthTypeAdapter;
|
||||
|
||||
public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) {
|
||||
Intent i = new Intent(context, AccountSetupIncoming.class);
|
||||
@ -149,22 +146,16 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
||||
};
|
||||
|
||||
// This needs to be kept in sync with the list at the top of the file.
|
||||
// that makes me somewhat unhappy
|
||||
SpinnerOption authTypeSpinnerOptions[] = {
|
||||
new SpinnerOption(0, AUTH_TYPES[0]),
|
||||
new SpinnerOption(1, AUTH_TYPES[1])
|
||||
};
|
||||
|
||||
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, authTypeSpinnerOptions);
|
||||
authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mAuthTypeView.setAdapter(authTypesAdapter);
|
||||
AuthType[] acceptableAuthTypes = {AuthType.PLAIN, AuthType.CRAM_MD5};
|
||||
mAuthTypeAdapter = new ArrayAdapter<AuthType>(this,
|
||||
android.R.layout.simple_spinner_item, acceptableAuthTypes);
|
||||
mAuthTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mAuthTypeView.setAdapter(mAuthTypeAdapter);
|
||||
|
||||
/*
|
||||
* Calls validateFields() which enables or disables the Next button
|
||||
@ -217,13 +208,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
mPasswordView.setText(settings.password);
|
||||
}
|
||||
|
||||
if (settings.authenticationType != null) {
|
||||
for (int i = 0; i < AUTH_TYPES.length; i++) {
|
||||
if (AUTH_TYPES[i].equals(settings.authenticationType)) {
|
||||
SpinnerOption.setSpinnerOptionValue(mAuthTypeView, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The first item is selected if settings.authenticationType is null or is not in mAuthTypeAdapter
|
||||
int position = mAuthTypeAdapter.getPosition(settings.authenticationType);
|
||||
mAuthTypeView.setSelection(position, false);
|
||||
|
||||
mStoreType = settings.type;
|
||||
if (Pop3Store.STORE_TYPE.equals(settings.type)) {
|
||||
@ -407,7 +394,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
|
||||
String username = mUsernameView.getText().toString();
|
||||
String password = mPasswordView.getText().toString();
|
||||
String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label;
|
||||
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
|
||||
String host = mServerView.getText().toString();
|
||||
int port = Integer.parseInt(mPortView.getText().toString());
|
||||
|
||||
|
@ -17,7 +17,7 @@ import com.fsck.k9.*;
|
||||
import com.fsck.k9.activity.K9Activity;
|
||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.mail.transport.SmtpTransport;
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
@ -48,13 +48,6 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
"webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
|
||||
};
|
||||
*/
|
||||
private static final String authTypes[] = {
|
||||
SmtpTransport.AUTH_AUTOMATIC,
|
||||
SmtpTransport.AUTH_LOGIN,
|
||||
SmtpTransport.AUTH_PLAIN,
|
||||
SmtpTransport.AUTH_CRAM_MD5,
|
||||
};
|
||||
|
||||
private EditText mUsernameView;
|
||||
private EditText mPasswordView;
|
||||
private EditText mServerView;
|
||||
@ -127,18 +120,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
||||
};
|
||||
|
||||
SpinnerOption authTypeSpinnerOptions[] = new SpinnerOption[authTypes.length];
|
||||
for (int i = 0; i < authTypes.length; i++) {
|
||||
authTypeSpinnerOptions[i] = new SpinnerOption(i, authTypes[i]);
|
||||
}
|
||||
|
||||
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, authTypeSpinnerOptions);
|
||||
ArrayAdapter<AuthType> authTypesAdapter = new ArrayAdapter<AuthType>(this,
|
||||
android.R.layout.simple_spinner_item, AuthType.values());
|
||||
authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mAuthTypeView.setAdapter(authTypesAdapter);
|
||||
|
||||
@ -208,11 +196,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
}
|
||||
|
||||
if (authType != null) {
|
||||
for (int i = 0; i < authTypes.length; i++) {
|
||||
if (authTypes[i].equals(authType)) {
|
||||
SpinnerOption.setSpinnerOptionValue(mAuthTypeView, i);
|
||||
}
|
||||
}
|
||||
int position = AuthType.valueOf(authType).ordinal();
|
||||
mAuthTypeView.setSelection(position, false);
|
||||
}
|
||||
|
||||
// Select currently configured security type
|
||||
@ -305,7 +290,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
String passwordEnc = URLEncoder.encode(mPasswordView.getText().toString(), "UTF-8");
|
||||
|
||||
String userInfo = null;
|
||||
String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label;
|
||||
String authType = ((AuthType) mAuthTypeView.getSelectedItem()).name();
|
||||
if (mRequireLoginView.isChecked()) {
|
||||
userInfo = usernameEnc + ":" + passwordEnc + ":" + authType;
|
||||
}
|
||||
|
32
src/com/fsck/k9/mail/AuthType.java
Normal file
32
src/com/fsck/k9/mail/AuthType.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.fsck.k9.mail;
|
||||
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.R;
|
||||
|
||||
public enum AuthType {
|
||||
|
||||
/*
|
||||
* The names of these auth. types are saved as strings when settings are
|
||||
* exported, and are also saved as part of the Server URI saved in the
|
||||
* account settings.
|
||||
*/
|
||||
AUTOMATIC(R.string.account_setup_auth_type_automatic),
|
||||
PLAIN(R.string.account_setup_auth_type_normal_password),
|
||||
CRAM_MD5(R.string.account_setup_auth_type_encrypted_password),
|
||||
LOGIN(0);
|
||||
|
||||
private final int mResourceId;
|
||||
|
||||
private AuthType(int id) {
|
||||
mResourceId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (mResourceId == 0) {
|
||||
return name();
|
||||
} else {
|
||||
return K9.app.getString(mResourceId);
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ public class ServerSettings {
|
||||
*
|
||||
* {@code null} if not applicable for the store or transport.
|
||||
*/
|
||||
public final String authenticationType;
|
||||
public final AuthType authenticationType;
|
||||
|
||||
/**
|
||||
* The username part of the credentials needed to authenticate to the server.
|
||||
@ -91,7 +91,7 @@ public class ServerSettings {
|
||||
* see {@link ServerSettings#password}
|
||||
*/
|
||||
public ServerSettings(String type, String host, int port,
|
||||
ConnectionSecurity connectionSecurity, String authenticationType, String username,
|
||||
ConnectionSecurity connectionSecurity, AuthType authenticationType, String username,
|
||||
String password) {
|
||||
this.type = type;
|
||||
this.host = host;
|
||||
@ -124,7 +124,7 @@ public class ServerSettings {
|
||||
* see {@link ServerSettings#extra}
|
||||
*/
|
||||
public ServerSettings(String type, String host, int port,
|
||||
ConnectionSecurity connectionSecurity, String authenticationType, String username,
|
||||
ConnectionSecurity connectionSecurity, AuthType authenticationType, String username,
|
||||
String password, Map<String, String> extra) {
|
||||
this.type = type;
|
||||
this.host = host;
|
||||
|
@ -69,6 +69,7 @@ import com.fsck.k9.helper.StringUtils;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.helper.power.TracingPowerManager;
|
||||
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.Authentication;
|
||||
import com.fsck.k9.mail.AuthenticationFailedException;
|
||||
import com.fsck.k9.mail.Body;
|
||||
@ -117,8 +118,6 @@ public class ImapStore extends Store {
|
||||
public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3;
|
||||
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
|
||||
|
||||
public enum AuthType { PLAIN, CRAM_MD5 }
|
||||
|
||||
private static final int IDLE_READ_TIMEOUT_INCREMENT = 5 * 60 * 1000;
|
||||
private static final int IDLE_FAILURE_COUNT_LIMIT = 10;
|
||||
private static int MAX_DELAY_TIME = 5 * 60 * 1000; // 5 minutes
|
||||
@ -163,7 +162,7 @@ public class ImapStore extends Store {
|
||||
String host;
|
||||
int port;
|
||||
ConnectionSecurity connectionSecurity;
|
||||
String authenticationType = null;
|
||||
AuthType authenticationType = null;
|
||||
String username = null;
|
||||
String password = null;
|
||||
String pathPrefix = null;
|
||||
@ -209,14 +208,14 @@ public class ImapStore extends Store {
|
||||
|
||||
if (userinfo.endsWith(":")) {
|
||||
// Password is empty. This can only happen after an account was imported.
|
||||
authenticationType = AuthType.valueOf(userInfoParts[0]).name();
|
||||
authenticationType = AuthType.valueOf(userInfoParts[0]);
|
||||
username = URLDecoder.decode(userInfoParts[1], "UTF-8");
|
||||
} else if (userInfoParts.length == 2) {
|
||||
authenticationType = AuthType.PLAIN.name();
|
||||
authenticationType = AuthType.PLAIN;
|
||||
username = URLDecoder.decode(userInfoParts[0], "UTF-8");
|
||||
password = URLDecoder.decode(userInfoParts[1], "UTF-8");
|
||||
} else {
|
||||
authenticationType = AuthType.valueOf(userInfoParts[0]).name();
|
||||
authenticationType = AuthType.valueOf(userInfoParts[0]);
|
||||
username = URLDecoder.decode(userInfoParts[1], "UTF-8");
|
||||
password = URLDecoder.decode(userInfoParts[2], "UTF-8");
|
||||
}
|
||||
@ -291,15 +290,9 @@ public class ImapStore extends Store {
|
||||
break;
|
||||
}
|
||||
|
||||
AuthType authType;
|
||||
try {
|
||||
authType = AuthType.valueOf(server.authenticationType);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid authentication type: " +
|
||||
server.authenticationType);
|
||||
}
|
||||
AuthType authType = server.authenticationType;
|
||||
|
||||
String userInfo = authType.toString() + ":" + userEnc + ":" + passwordEnc;
|
||||
String userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;
|
||||
try {
|
||||
Map<String, String> extra = server.getExtra();
|
||||
String path = null;
|
||||
@ -334,7 +327,7 @@ public class ImapStore extends Store {
|
||||
public final String pathPrefix;
|
||||
|
||||
protected ImapStoreSettings(String host, int port, ConnectionSecurity connectionSecurity,
|
||||
String authenticationType, String username, String password,
|
||||
AuthType authenticationType, String username, String password,
|
||||
boolean autodetectNamespace, String pathPrefix) {
|
||||
super(STORE_TYPE, host, port, connectionSecurity, authenticationType, username,
|
||||
password);
|
||||
@ -485,7 +478,7 @@ public class ImapStore extends Store {
|
||||
break;
|
||||
}
|
||||
|
||||
mAuthType = AuthType.valueOf(settings.authenticationType);
|
||||
mAuthType = settings.authenticationType;
|
||||
mUsername = settings.username;
|
||||
mPassword = settings.password;
|
||||
|
||||
|
@ -43,11 +43,6 @@ public class Pop3Store extends Store {
|
||||
public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3;
|
||||
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
|
||||
|
||||
private enum AuthType {
|
||||
PLAIN,
|
||||
CRAM_MD5
|
||||
}
|
||||
|
||||
private static final String STLS_COMMAND = "STLS";
|
||||
private static final String USER_COMMAND = "USER";
|
||||
private static final String PASS_COMMAND = "PASS";
|
||||
@ -120,7 +115,7 @@ public class Pop3Store extends Store {
|
||||
port = pop3Uri.getPort();
|
||||
}
|
||||
|
||||
String authType = AuthType.PLAIN.name();
|
||||
AuthType authType = AuthType.PLAIN;
|
||||
if (pop3Uri.getUserInfo() != null) {
|
||||
try {
|
||||
int userIndex = 0, passwordIndex = 1;
|
||||
@ -131,7 +126,7 @@ public class Pop3Store extends Store {
|
||||
// after an account was imported (so authType and username are present).
|
||||
userIndex++;
|
||||
passwordIndex++;
|
||||
authType = userInfoParts[0];
|
||||
authType = AuthType.valueOf(userInfoParts[0]);
|
||||
}
|
||||
username = URLDecoder.decode(userInfoParts[userIndex], "UTF-8");
|
||||
if (userInfoParts.length > passwordIndex) {
|
||||
@ -190,14 +185,7 @@ public class Pop3Store extends Store {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
AuthType.valueOf(server.authenticationType);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid authentication type (" +
|
||||
server.authenticationType + ")");
|
||||
}
|
||||
|
||||
String userInfo = server.authenticationType + ":" + userEnc + ":" + passwordEnc;
|
||||
String userInfo = server.authenticationType.name() + ":" + userEnc + ":" + passwordEnc;
|
||||
try {
|
||||
return new URI(scheme, userInfo, server.host, server.port, null, null,
|
||||
null).toString();
|
||||
@ -257,7 +245,7 @@ public class Pop3Store extends Store {
|
||||
|
||||
mUsername = settings.username;
|
||||
mPassword = settings.password;
|
||||
mAuthType = AuthType.valueOf(settings.authenticationType);
|
||||
mAuthType = settings.authenticationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -270,7 +270,7 @@ public class WebDavStore extends Store {
|
||||
public final String mailboxPath;
|
||||
|
||||
protected WebDavStoreSettings(String host, int port, ConnectionSecurity connectionSecurity,
|
||||
String authenticationType, String username, String password, String alias,
|
||||
AuthType authenticationType, String username, String password, String alias,
|
||||
String path, String authPath, String mailboxPath) {
|
||||
super(STORE_TYPE, host, port, connectionSecurity, authenticationType, username,
|
||||
password);
|
||||
|
@ -39,15 +39,6 @@ public class SmtpTransport extends Transport {
|
||||
public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3;
|
||||
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
|
||||
|
||||
public static final String AUTH_PLAIN = "PLAIN";
|
||||
|
||||
public static final String AUTH_CRAM_MD5 = "CRAM_MD5";
|
||||
|
||||
public static final String AUTH_LOGIN = "LOGIN";
|
||||
|
||||
public static final String AUTH_AUTOMATIC = "AUTOMATIC";
|
||||
|
||||
|
||||
/**
|
||||
* Decodes a SmtpTransport URI.
|
||||
*
|
||||
@ -64,7 +55,7 @@ public class SmtpTransport extends Transport {
|
||||
String host;
|
||||
int port;
|
||||
ConnectionSecurity connectionSecurity;
|
||||
String authenticationType = AUTH_AUTOMATIC;
|
||||
AuthType authType = AuthType.AUTOMATIC;
|
||||
String username = null;
|
||||
String password = null;
|
||||
|
||||
@ -109,7 +100,7 @@ public class SmtpTransport extends Transport {
|
||||
password = URLDecoder.decode(userInfoParts[1], "UTF-8");
|
||||
}
|
||||
if (userInfoParts.length > 2) {
|
||||
authenticationType = userInfoParts[2];
|
||||
authType = AuthType.valueOf(userInfoParts[2]);
|
||||
}
|
||||
} catch (UnsupportedEncodingException enc) {
|
||||
// This shouldn't happen since the encoding is hardcoded to UTF-8
|
||||
@ -118,7 +109,7 @@ public class SmtpTransport extends Transport {
|
||||
}
|
||||
|
||||
return new ServerSettings(TRANSPORT_TYPE, host, port, connectionSecurity,
|
||||
authenticationType, username, password);
|
||||
authType, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,15 +156,11 @@ public class SmtpTransport extends Transport {
|
||||
break;
|
||||
}
|
||||
|
||||
String authType = server.authenticationType;
|
||||
if (!(AUTH_AUTOMATIC.equals(authType) ||
|
||||
AUTH_LOGIN.equals(authType) ||
|
||||
AUTH_PLAIN.equals(authType) ||
|
||||
AUTH_CRAM_MD5.equals(authType))) {
|
||||
throw new IllegalArgumentException("Invalid authentication type: " + authType);
|
||||
String userInfo = userEnc + ":" + passwordEnc;
|
||||
AuthType authType = server.authenticationType;
|
||||
if (authType != null) {
|
||||
userInfo += ":" + authType.name();
|
||||
}
|
||||
|
||||
String userInfo = userEnc + ":" + passwordEnc + ":" + authType;
|
||||
try {
|
||||
return new URI(scheme, userInfo, server.host, server.port, null, null,
|
||||
null).toString();
|
||||
@ -187,7 +174,7 @@ public class SmtpTransport extends Transport {
|
||||
int mPort;
|
||||
String mUsername;
|
||||
String mPassword;
|
||||
String mAuthType;
|
||||
AuthType mAuthType;
|
||||
int mConnectionSecurity;
|
||||
Socket mSocket;
|
||||
PeekableInputStream mIn;
|
||||
@ -318,9 +305,9 @@ public class SmtpTransport extends Transport {
|
||||
}
|
||||
}
|
||||
|
||||
boolean useAuthLogin = AUTH_LOGIN.equals(mAuthType);
|
||||
boolean useAuthPlain = AUTH_PLAIN.equals(mAuthType);
|
||||
boolean useAuthCramMD5 = AUTH_CRAM_MD5.equals(mAuthType);
|
||||
boolean useAuthLogin = AuthType.LOGIN.equals(mAuthType);
|
||||
boolean useAuthPlain = AuthType.PLAIN.equals(mAuthType);
|
||||
boolean useAuthCramMD5 = AuthType.CRAM_MD5.equals(mAuthType);
|
||||
|
||||
// Automatically choose best authentication method if none was explicitly selected
|
||||
boolean useAutomaticAuth = !(useAuthLogin || useAuthPlain || useAuthCramMD5);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.fsck.k9.mail.transport.imap;
|
||||
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.store.ImapStore;
|
||||
import com.fsck.k9.mail.store.ImapStore.AuthType;
|
||||
import com.fsck.k9.mail.store.ImapStore.ImapConnection;
|
||||
|
||||
/**
|
||||
|
@ -230,7 +230,7 @@ public class SettingsExporter {
|
||||
writeElement(serializer, PORT_ELEMENT, Integer.toString(incoming.port));
|
||||
}
|
||||
writeElement(serializer, CONNECTION_SECURITY_ELEMENT, incoming.connectionSecurity.name());
|
||||
writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, incoming.authenticationType);
|
||||
writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, incoming.authenticationType.name());
|
||||
writeElement(serializer, USERNAME_ELEMENT, incoming.username);
|
||||
// XXX For now we don't export the password
|
||||
//writeElement(serializer, PASSWORD_ELEMENT, incoming.password);
|
||||
@ -257,7 +257,7 @@ public class SettingsExporter {
|
||||
writeElement(serializer, PORT_ELEMENT, Integer.toString(outgoing.port));
|
||||
}
|
||||
writeElement(serializer, CONNECTION_SECURITY_ELEMENT, outgoing.connectionSecurity.name());
|
||||
writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, outgoing.authenticationType);
|
||||
writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, outgoing.authenticationType.name());
|
||||
writeElement(serializer, USERNAME_ELEMENT, outgoing.username);
|
||||
// XXX For now we don't export the password
|
||||
//writeElement(serializer, PASSWORD_ELEMENT, outgoing.password);
|
||||
|
@ -23,6 +23,7 @@ import com.fsck.k9.Identity;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
import com.fsck.k9.mail.ServerSettings;
|
||||
import com.fsck.k9.mail.Store;
|
||||
@ -971,7 +972,8 @@ public class SettingsImporter {
|
||||
} else if (SettingsExporter.CONNECTION_SECURITY_ELEMENT.equals(element)) {
|
||||
server.connectionSecurity = getText(xpp);
|
||||
} else if (SettingsExporter.AUTHENTICATION_TYPE_ELEMENT.equals(element)) {
|
||||
server.authenticationType = getText(xpp);
|
||||
String text = getText(xpp);
|
||||
server.authenticationType = AuthType.valueOf(text);
|
||||
} else if (SettingsExporter.USERNAME_ELEMENT.equals(element)) {
|
||||
server.username = getText(xpp);
|
||||
} else if (SettingsExporter.PASSWORD_ELEMENT.equals(element)) {
|
||||
@ -1140,7 +1142,7 @@ public class SettingsImporter {
|
||||
public String host;
|
||||
public String port;
|
||||
public String connectionSecurity;
|
||||
public String authenticationType;
|
||||
public AuthType authenticationType;
|
||||
public String username;
|
||||
public String password;
|
||||
public ImportedSettings extras;
|
||||
|
@ -2,6 +2,8 @@ package com.fsck.k9.mail.store;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
import com.fsck.k9.mail.ServerSettings;
|
||||
import com.fsck.k9.mail.Store;
|
||||
@ -13,7 +15,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/0%7CcustomPathPrefix";
|
||||
ServerSettings settings = Store.decodeStoreUri(uri);
|
||||
|
||||
assertEquals("PLAIN", settings.authenticationType);
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
assertEquals("pass", settings.password);
|
||||
assertEquals("server", settings.host);
|
||||
@ -26,7 +28,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/";
|
||||
ServerSettings settings = Store.decodeStoreUri(uri);
|
||||
|
||||
assertEquals("PLAIN", settings.authenticationType);
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
assertEquals("pass", settings.password);
|
||||
assertEquals("server", settings.host);
|
||||
@ -38,7 +40,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/customPathPrefix";
|
||||
ServerSettings settings = Store.decodeStoreUri(uri);
|
||||
|
||||
assertEquals("PLAIN", settings.authenticationType);
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
assertEquals("pass", settings.password);
|
||||
assertEquals("server", settings.host);
|
||||
@ -51,7 +53,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/0%7C";
|
||||
ServerSettings settings = Store.decodeStoreUri(uri);
|
||||
|
||||
assertEquals("PLAIN", settings.authenticationType);
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
assertEquals("pass", settings.password);
|
||||
assertEquals("server", settings.host);
|
||||
@ -64,7 +66,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/1%7CcustomPathPrefix";
|
||||
ServerSettings settings = Store.decodeStoreUri(uri);
|
||||
|
||||
assertEquals("PLAIN", settings.authenticationType);
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
assertEquals("pass", settings.password);
|
||||
assertEquals("server", settings.host);
|
||||
@ -80,7 +82,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
extra.put("pathPrefix", "customPathPrefix");
|
||||
|
||||
ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143,
|
||||
ConnectionSecurity.NONE, "PLAIN", "user", "pass", extra);
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", extra);
|
||||
|
||||
String uri = Store.createStoreUri(settings);
|
||||
|
||||
@ -93,7 +95,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
extra.put("pathPrefix", "");
|
||||
|
||||
ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143,
|
||||
ConnectionSecurity.NONE, "PLAIN", "user", "pass", extra);
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", extra);
|
||||
|
||||
String uri = Store.createStoreUri(settings);
|
||||
|
||||
@ -102,7 +104,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
|
||||
public void testCreateStoreUriImapNoExtra() {
|
||||
ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143,
|
||||
ConnectionSecurity.NONE, "PLAIN", "user", "pass");
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass");
|
||||
|
||||
String uri = Store.createStoreUri(settings);
|
||||
|
||||
@ -114,7 +116,7 @@ public class ImapStoreUriTest extends TestCase {
|
||||
extra.put("autoDetectNamespace", "true");
|
||||
|
||||
ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143,
|
||||
ConnectionSecurity.NONE, "PLAIN", "user", "pass", extra);
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", extra);
|
||||
|
||||
String uri = Store.createStoreUri(settings);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user