mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-08 20:28:34 -05:00
Tied it all together, very rough working version of the setup is in place now.
This commit is contained in:
parent
854c0e51d4
commit
a645ea08b3
@ -12,14 +12,12 @@ package com.fsck.k9.activity.setup;
|
|||||||
'browse' through the available hosts. This consists of 2 auto hidden/unhidden buttons and the necessary callbacks.
|
'browse' through the available hosts. This consists of 2 auto hidden/unhidden buttons and the necessary callbacks.
|
||||||
The need for this is questionable, if the devs/community decide for, I'll finish the code, if not it will be removed.
|
The need for this is questionable, if the devs/community decide for, I'll finish the code, if not it will be removed.
|
||||||
*/
|
*/
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.method.MovementMethod;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
@ -38,29 +36,14 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class AbstractSetupConfirmActivity extends K9Activity implements View.OnClickListener, OnItemSelectedListener {
|
public abstract class AbstractSetupConfirmActivity extends K9Activity implements View.OnClickListener, OnItemSelectedListener {
|
||||||
|
|
||||||
private static final String EXTRA_ACCOUNT = "account";
|
protected static final String EXTRA_ACCOUNT = "account";
|
||||||
private static final String EXTRA_CONFIG_INFO = "configInfo";
|
protected static final String EXTRA_CONFIG_INFO = "configInfo";
|
||||||
private static final String EXTRA_EMAIL = "email";
|
protected static final String EXTRA_EMAIL = "email";
|
||||||
private static final String EXTRA_PASSWORD = "password";
|
protected static final String EXTRA_PASSWORD = "password";
|
||||||
|
|
||||||
private final String LOCALPART_EMAIL = "%EMAILLOCALPART%";
|
private final String LOCALPART_EMAIL = "%EMAILLOCALPART%";
|
||||||
private final String WHOLE_EMAIL = "%EMAILADDRESS%";
|
private final String WHOLE_EMAIL = "%EMAILADDRESS%";
|
||||||
|
|
||||||
public static void actionConfirmIncoming(Context context, Account account, AutoconfigInfo info) {
|
|
||||||
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
|
||||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
|
||||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
|
||||||
context.startActivity(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void actionConfirmIncoming(Context context, String email, String password, AutoconfigInfo info){
|
|
||||||
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
|
||||||
i.putExtra(EXTRA_EMAIL, email);
|
|
||||||
i.putExtra(EXTRA_PASSWORD, password);
|
|
||||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
|
||||||
context.startActivity(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// data
|
// data
|
||||||
protected Account mAccount;
|
protected Account mAccount;
|
||||||
protected AutoconfigInfo mConfigInfo;
|
protected AutoconfigInfo mConfigInfo;
|
||||||
@ -116,7 +99,7 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
|||||||
mPassword = getIntent().getStringExtra(EXTRA_PASSWORD);
|
mPassword = getIntent().getStringExtra(EXTRA_PASSWORD);
|
||||||
|
|
||||||
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||||
if(accountUuid != null)
|
if(accountUuid != null && !accountUuid.isEmpty())
|
||||||
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
||||||
else mAccount = Account.getBlankAccount(this, mEmail, mPassword);
|
else mAccount = Account.getBlankAccount(this, mEmail, mPassword);
|
||||||
|
|
||||||
@ -164,7 +147,6 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
|||||||
switch( view.getId() ){
|
switch( view.getId() ){
|
||||||
case R.id.confirm_ok_button:
|
case R.id.confirm_ok_button:
|
||||||
finishAction();
|
finishAction();
|
||||||
finish();
|
|
||||||
break;
|
break;
|
||||||
case R.id.confirm_next_server_button:
|
case R.id.confirm_next_server_button:
|
||||||
// TODO: write this,... it will probably never be used since no isp has 2 host for exact the same thing
|
// TODO: write this,... it will probably never be used since no isp has 2 host for exact the same thing
|
||||||
|
@ -384,7 +384,7 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
|
|||||||
// launch confirm activities
|
// launch confirm activities
|
||||||
}else{
|
}else{
|
||||||
AccountSetupConfirmIncoming.actionConfirmIncoming
|
AccountSetupConfirmIncoming.actionConfirmIncoming
|
||||||
(this, mEmailAddress, mPassword, mAutoConfigInfo);
|
(this, null, mEmailAddress, mPassword, mAutoConfigInfo);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -6,7 +6,10 @@ package com.fsck.k9.activity.setup;
|
|||||||
the final settings.
|
the final settings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import com.fsck.k9.Account;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
|
||||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
|
||||||
@ -19,6 +22,19 @@ import java.net.URLEncoder;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity {
|
public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity {
|
||||||
|
|
||||||
|
// account is allowed to be null
|
||||||
|
public static void actionConfirmIncoming(Context context, Account account, String email, String password, AutoconfigInfo info) {
|
||||||
|
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
||||||
|
if( account != null )
|
||||||
|
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||||
|
else i.putExtra(EXTRA_ACCOUNT, "");
|
||||||
|
i.putExtra(EXTRA_EMAIL, email);
|
||||||
|
i.putExtra(EXTRA_PASSWORD, password);
|
||||||
|
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||||
|
context.startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<? extends AutoconfigInfo.Server> getServers() {
|
protected List<? extends AutoconfigInfo.Server> getServers() {
|
||||||
return mConfigInfo.incomingServer;
|
return mConfigInfo.incomingServer;
|
||||||
@ -42,7 +58,9 @@ public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity {
|
|||||||
mCurrentServer.hostname,
|
mCurrentServer.hostname,
|
||||||
mCurrentServer.port,
|
mCurrentServer.port,
|
||||||
null,null,null);
|
null,null,null);
|
||||||
mAccount.setTransportUri(uri.toString());
|
mAccount.setStoreUri(uri.toString());
|
||||||
|
|
||||||
|
AccountSetupConfirmOutgoing.actionConfirmOutgoing(this, mAccount, mEmail, mPassword, mConfigInfo);
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException enc) {}
|
catch (UnsupportedEncodingException enc) {}
|
||||||
catch (URISyntaxException use) {
|
catch (URISyntaxException use) {
|
||||||
@ -51,5 +69,6 @@ public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity {
|
|||||||
* convenience.
|
* convenience.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,33 @@ package com.fsck.k9.activity.setup;
|
|||||||
the final settings.
|
the final settings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.fsck.k9.Account;
|
||||||
|
import com.fsck.k9.K9;
|
||||||
|
import com.fsck.k9.Preferences;
|
||||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
|
||||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
|
||||||
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.AuthenticationType;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AccountSetupConfirmOutgoing extends AbstractSetupConfirmActivity{
|
public class AccountSetupConfirmOutgoing extends AbstractSetupConfirmActivity{
|
||||||
|
|
||||||
|
// account is allowed to be null
|
||||||
|
public static void actionConfirmOutgoing(Context context, Account account, String email, String password, AutoconfigInfo info) {
|
||||||
|
Intent i = new Intent(context, AccountSetupConfirmOutgoing.class);
|
||||||
|
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||||
|
i.putExtra(EXTRA_EMAIL, email);
|
||||||
|
i.putExtra(EXTRA_PASSWORD, password);
|
||||||
|
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||||
|
context.startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<? extends AutoconfigInfo.Server> getServers() {
|
protected List<? extends AutoconfigInfo.Server> getServers() {
|
||||||
return mConfigInfo.outgoingServer;
|
return mConfigInfo.outgoingServer;
|
||||||
@ -23,6 +45,53 @@ public class AccountSetupConfirmOutgoing extends AbstractSetupConfirmActivity{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finishAction() {
|
protected void finishAction() {
|
||||||
//To change body of implemented methods use File | Settings | File Templates.
|
try {
|
||||||
|
String userInfo = null;
|
||||||
|
|
||||||
|
// check if authentication is required
|
||||||
|
if (mCurrentServer.authentication != AuthenticationType.none &&
|
||||||
|
mCurrentServer.authentication != AuthenticationType.clientIPaddress )
|
||||||
|
{
|
||||||
|
userInfo = URLEncoder.encode(mUsername, "UTF-8") + ":" +
|
||||||
|
URLEncoder.encode(mPassword, "UTF-8") + ":" +
|
||||||
|
mCurrentServer.authentication.getAuthString();
|
||||||
|
}
|
||||||
|
|
||||||
|
URI uri = new URI(
|
||||||
|
getScheme(),
|
||||||
|
userInfo,
|
||||||
|
mCurrentServer.hostname,
|
||||||
|
mCurrentServer.port,
|
||||||
|
null,null,null);
|
||||||
|
|
||||||
|
mAccount.setTransportUri(uri.toString());
|
||||||
|
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, true);
|
||||||
|
|
||||||
|
} catch (UnsupportedEncodingException enc) {
|
||||||
|
// This really shouldn't happen since the encoding is hardcoded to UTF-8
|
||||||
|
Log.e(K9.LOG_TAG, "Couldn't urlencode username or password.", enc);
|
||||||
|
} catch (Exception e) {
|
||||||
|
/*
|
||||||
|
* It's unrecoverable if we cannot create a URI from components that
|
||||||
|
* we validated to be safe.
|
||||||
|
*/
|
||||||
|
// TODO: handle this
|
||||||
|
//failure(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
||||||
|
mAccount.save(Preferences.getPreferences(this));
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
// have to pop up to ask if it should be default account now
|
||||||
|
// hard-coded now for test purposes
|
||||||
|
AccountSetupOptions.actionOptions(this, mAccount, true);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -186,6 +186,7 @@ public class AccountSetupIndex extends K9ListActivity implements OnItemClickList
|
|||||||
|
|
||||||
private void startSettingsDetection(String email, String password) {
|
private void startSettingsDetection(String email, String password) {
|
||||||
AccountSetupAutoConfiguration.actionAttemptConfiguration(this, email, password);
|
AccountSetupAutoConfiguration.actionAttemptConfiguration(this, email, password);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
package com.fsck.k9.helper.configxmlparser;
|
package com.fsck.k9.helper.configxmlparser;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -52,7 +55,24 @@ public class AutoconfigInfo implements Parcelable {
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Define types for some of the data
|
Define types for some of the data
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static enum AuthenticationType { plain, secure, NTLM, GSSAPI, clientIPaddress, TLSclientcert, none, UNSET };
|
public static enum AuthenticationType {
|
||||||
|
plain(1), secure(2), NTLM(-1), GSSAPI(-1), clientIPaddress(0), TLSclientcert(-1), none(0), UNSET(-1);
|
||||||
|
/*
|
||||||
|
K-9 only supports plain or CRAM-MD5 so we'll toss an error for all the rest and just check this manually
|
||||||
|
*/
|
||||||
|
private int type;
|
||||||
|
AuthenticationType(int type){ this.type = type; }
|
||||||
|
|
||||||
|
public String getAuthString() throws UnsupportedEncodingException {
|
||||||
|
switch( type ){
|
||||||
|
case 0: return "";
|
||||||
|
case 1: return "PLAIN";
|
||||||
|
case 2: return "CRAM_MD5";
|
||||||
|
default: throw new UnsupportedEncodingException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public static enum SocketType { plain(""), SSL("ssl"), STARTTLS("tls"), UNSET("");
|
public static enum SocketType { plain(""), SSL("ssl"), STARTTLS("tls"), UNSET("");
|
||||||
private String schemeName;
|
private String schemeName;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user