From 1cda221fa3cf40580ec6e25910f1661ab3c10135 Mon Sep 17 00:00:00 2001 From: Matthew Brace Date: Wed, 21 Jan 2009 05:27:22 +0000 Subject: [PATCH] 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. --- res/layout/account_setup_incoming.xml | 13 ++++++++++++- res/values/strings.xml | 2 +- .../email/activity/setup/AccountSetupIncoming.java | 12 +++++++++++- src/com/android/email/mail/store/WebDavStore.java | 10 ++++++++-- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/res/layout/account_setup_incoming.xml b/res/layout/account_setup_incoming.xml index fa06a6d27..9f60731ed 100644 --- a/res/layout/account_setup_incoming.xml +++ b/res/layout/account_setup_incoming.xml @@ -99,8 +99,19 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> + + - IMAP path prefix Optional - WebDav(Exchange) path prefix + WebDav(Exchange) path Optional Outgoing server settings diff --git a/src/com/android/email/activity/setup/AccountSetupIncoming.java b/src/com/android/email/activity/setup/AccountSetupIncoming.java index 0bc815344..86878989d 100644 --- a/src/com/android/email/activity/setup/AccountSetupIncoming.java +++ b/src/com/android/email/activity/setup/AccountSetupIncoming.java @@ -60,6 +60,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener { private Spinner mSecurityTypeView; private Spinner mDeletePolicyView; private EditText mImapPathPrefixView; + private EditText mWebdavPathPrefixView; private Button mNextButton; private Account mAccount; private boolean mMakeDefault; @@ -91,6 +92,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener { mSecurityTypeView = (Spinner)findViewById(R.id.account_security_type); mDeletePolicyView = (Spinner)findViewById(R.id.account_delete_policy); mImapPathPrefixView = (EditText)findViewById(R.id.imap_path_prefix); + mWebdavPathPrefixView = (EditText)findViewById(R.id.webdav_path_prefix); mNextButton = (Button)findViewById(R.id.next); mNextButton.setOnClickListener(this); @@ -203,6 +205,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener { mAccountSchemes = popSchemes; 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")) { serverLabelView.setText(R.string.account_setup_incoming_imap_server_label); mAccountPorts = imapPorts; @@ -211,6 +214,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener { if (uri.getPath() != null && uri.getPath().length() > 0) { mImapPathPrefixView.setText(uri.getPath().substring(1)); } + findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE); } else if (uri.getScheme().startsWith("webdav")) { serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label); mAccountPorts = webdavPorts; @@ -218,6 +222,9 @@ public class AccountSetupIncoming extends Activity implements OnClickListener { /** Hide the unnecessary fields */ 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 { throw new Error("Unknown account type: " + mAccount.getStoreUri()); } @@ -311,7 +318,10 @@ public class AccountSetupIncoming extends Activity implements OnClickListener { String path = null; if (mAccountSchemes[securityType].startsWith("imap")) { path = "/" + mImapPathPrefixView.getText(); - } + } else if (mAccountSchemes[securityType].startsWith("webdav")) { + path = "/" + mWebdavPathPrefixView.getText(); + } + URI uri = new URI( mAccountSchemes[securityType], mUsernameView.getText() + ":" + mPasswordView.getText(), diff --git a/src/com/android/email/mail/store/WebDavStore.java b/src/com/android/email/mail/store/WebDavStore.java index 87516fae1..9dd1955da 100644 --- a/src/com/android/email/mail/store/WebDavStore.java +++ b/src/com/android/email/mail/store/WebDavStore.java @@ -84,6 +84,7 @@ public class WebDavStore extends Store { private String mPassword; /* Stores the password for authentications */ private String mUrl; /* Stores the base URL 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 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 || mConnectionSecurity == CONNECTION_SECURITY_SSL_REQUIRED || mConnectionSecurity == CONNECTION_SECURITY_TLS_OPTIONAL || mConnectionSecurity == CONNECTION_SECURITY_SSL_OPTIONAL) { - this.mUrl = "https://" + mHost + ":" + mUri.getPort(); + this.mUrl = "https://" + mHost + ":" + mUri.getPort() + mPath; } else { - this.mUrl = "http://" + mHost + ":" + mUri.getPort(); + this.mUrl = "http://" + mHost + ":" + mUri.getPort() + mPath; } if (mUri.getUserInfo() != null) {