1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Added support for Exchange path. This is not specifying the path for authentication or for the mailbox. This is support for situations like "https://www.myserver.com/owapath" for authentication.

This commit is contained in:
Matthew Brace 2009-01-21 05:27:22 +00:00
parent b7ad91b7a5
commit 1cda221fa3
4 changed files with 32 additions and 5 deletions

View File

@ -99,8 +99,19 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:text="@string/account_setup_incoming_webdav_path_prefix_label"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
<EditText
android:id="@+id/webdav_path_prefix"
android:hint="@string/account_setup_incoming_imap_path_prefix_hint"
android:singleLine="true"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
</LinearLayout> </LinearLayout>
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0px" android:layout_height="0px"

View File

@ -220,7 +220,7 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
<string name="account_setup_incoming_imap_path_prefix_label">IMAP path prefix</string> <string name="account_setup_incoming_imap_path_prefix_label">IMAP path prefix</string>
<string name="account_setup_incoming_imap_path_prefix_hint">Optional</string> <string name="account_setup_incoming_imap_path_prefix_hint">Optional</string>
<string name="account_setup_incoming_webdav_path_prefix_label">WebDav(Exchange) path prefix</string> <string name="account_setup_incoming_webdav_path_prefix_label">WebDav(Exchange) path</string>
<string name="account_setup_incoming_webdav_path_prefix_hint">Optional</string> <string name="account_setup_incoming_webdav_path_prefix_hint">Optional</string>
<string name="account_setup_outgoing_title">Outgoing server settings</string> <string name="account_setup_outgoing_title">Outgoing server settings</string>

View File

@ -60,6 +60,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
private Spinner mSecurityTypeView; private Spinner mSecurityTypeView;
private Spinner mDeletePolicyView; private Spinner mDeletePolicyView;
private EditText mImapPathPrefixView; private EditText mImapPathPrefixView;
private EditText mWebdavPathPrefixView;
private Button mNextButton; private Button mNextButton;
private Account mAccount; private Account mAccount;
private boolean mMakeDefault; private boolean mMakeDefault;
@ -91,6 +92,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
mSecurityTypeView = (Spinner)findViewById(R.id.account_security_type); mSecurityTypeView = (Spinner)findViewById(R.id.account_security_type);
mDeletePolicyView = (Spinner)findViewById(R.id.account_delete_policy); mDeletePolicyView = (Spinner)findViewById(R.id.account_delete_policy);
mImapPathPrefixView = (EditText)findViewById(R.id.imap_path_prefix); mImapPathPrefixView = (EditText)findViewById(R.id.imap_path_prefix);
mWebdavPathPrefixView = (EditText)findViewById(R.id.webdav_path_prefix);
mNextButton = (Button)findViewById(R.id.next); mNextButton = (Button)findViewById(R.id.next);
mNextButton.setOnClickListener(this); mNextButton.setOnClickListener(this);
@ -203,6 +205,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
mAccountSchemes = popSchemes; mAccountSchemes = popSchemes;
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE); findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE);
} else if (uri.getScheme().startsWith("imap")) { } else if (uri.getScheme().startsWith("imap")) {
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label); serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
mAccountPorts = imapPorts; mAccountPorts = imapPorts;
@ -211,6 +214,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
if (uri.getPath() != null && uri.getPath().length() > 0) { if (uri.getPath() != null && uri.getPath().length() > 0) {
mImapPathPrefixView.setText(uri.getPath().substring(1)); mImapPathPrefixView.setText(uri.getPath().substring(1));
} }
findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE);
} else if (uri.getScheme().startsWith("webdav")) { } else if (uri.getScheme().startsWith("webdav")) {
serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label); serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label);
mAccountPorts = webdavPorts; mAccountPorts = webdavPorts;
@ -218,6 +222,9 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
/** Hide the unnecessary fields */ /** Hide the unnecessary fields */
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE); findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
if (uri.getPath() != null && uri.getPath().length() > 0) {
mWebdavPathPrefixView.setText(uri.getPath().substring(1));
}
} else { } else {
throw new Error("Unknown account type: " + mAccount.getStoreUri()); throw new Error("Unknown account type: " + mAccount.getStoreUri());
} }
@ -311,7 +318,10 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
String path = null; String path = null;
if (mAccountSchemes[securityType].startsWith("imap")) { if (mAccountSchemes[securityType].startsWith("imap")) {
path = "/" + mImapPathPrefixView.getText(); path = "/" + mImapPathPrefixView.getText();
} else if (mAccountSchemes[securityType].startsWith("webdav")) {
path = "/" + mWebdavPathPrefixView.getText();
} }
URI uri = new URI( URI uri = new URI(
mAccountSchemes[securityType], mAccountSchemes[securityType],
mUsernameView.getText() + ":" + mPasswordView.getText(), mUsernameView.getText() + ":" + mPasswordView.getText(),

View File

@ -84,6 +84,7 @@ public class WebDavStore extends Store {
private String mPassword; /* Stores the password for authentications */ private String mPassword; /* Stores the password for authentications */
private String mUrl; /* Stores the base URL for the server */ private String mUrl; /* Stores the base URL for the server */
private String mHost; /* Stores the host name for the server */ private String mHost; /* Stores the host name for the server */
private String mPath; /* Stores the path for the server */
private URI mUri; /* Stores the Uniform Resource Indicator with all connection info */ private URI mUri; /* Stores the Uniform Resource Indicator with all connection info */
private CookieStore mAuthCookies; /* Stores cookies from authentication */ private CookieStore mAuthCookies; /* Stores cookies from authentication */
@ -133,13 +134,18 @@ public class WebDavStore extends Store {
} }
} }
mPath = mUri.getPath();
if (mPath == null) {
mPath = "";
}
if (mConnectionSecurity == CONNECTION_SECURITY_TLS_REQUIRED || if (mConnectionSecurity == CONNECTION_SECURITY_TLS_REQUIRED ||
mConnectionSecurity == CONNECTION_SECURITY_SSL_REQUIRED || mConnectionSecurity == CONNECTION_SECURITY_SSL_REQUIRED ||
mConnectionSecurity == CONNECTION_SECURITY_TLS_OPTIONAL || mConnectionSecurity == CONNECTION_SECURITY_TLS_OPTIONAL ||
mConnectionSecurity == CONNECTION_SECURITY_SSL_OPTIONAL) { mConnectionSecurity == CONNECTION_SECURITY_SSL_OPTIONAL) {
this.mUrl = "https://" + mHost + ":" + mUri.getPort(); this.mUrl = "https://" + mHost + ":" + mUri.getPort() + mPath;
} else { } else {
this.mUrl = "http://" + mHost + ":" + mUri.getPort(); this.mUrl = "http://" + mHost + ":" + mUri.getPort() + mPath;
} }
if (mUri.getUserInfo() != null) { if (mUri.getUserInfo() != null) {