private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT";\r
private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON";\r
private static final String KEY_SERVER_AUTH_METHOD = "SERVER_AUTH_METHOD";\r
- private static final String KEY_WAITING_FOR_OP_ID = "DETECT_AUTH_OP_ID";\r
+ private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";\r
private static final String KEY_AUTH_TOKEN = "AUTH_TOKEN";\r
\r
private static final String AUTH_ON = "on";\r
\r
private boolean mServerIsChecked = false;\r
private boolean mServerIsValid = false;\r
+ private boolean mPendingAutoCheck = false;\r
\r
private GetServerInfoOperation.ServerInfo mServerInfo = \r
new GetServerInfoOperation.ServerInfo();\r
\r
/// Identifier of operation in progress which result shouldn't be lost \r
private long mWaitingForOpId = Long.MAX_VALUE;\r
- \r
+\r
\r
/**\r
* {@inheritDoc}\r
});\r
\r
\r
- /// step 4 - automatic actions to start\r
- if (savedInstanceState == null) {\r
- if (mAction != ACTION_CREATE || !isUrlInputAllowed) {\r
- checkOcServer(); \r
- }\r
- }\r
+ /// step 4 - mark automatic check to be started when OperationsService is ready\r
+ mPendingAutoCheck = (savedInstanceState == null && \r
+ (mAction != ACTION_CREATE || !isUrlInputAllowed));\r
}\r
\r
\r
if (mOperationsServiceBinder != null) {\r
//Log_OC.wtf(TAG, "checking server..." );\r
mWaitingForOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent);\r
+ } else {\r
+ Log_OC.wtf(TAG, "Server check tried with OperationService unbound!" );\r
}\r
\r
} else {\r
* the root folder of the ownCloud server.\r
*/\r
private void checkBasicAuthorization() {\r
- /// get the path to the root folder through WebDAV from the version server\r
- String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);\r
-\r
/// get basic credentials entered by user\r
String username = mUsernameInput.getText().toString();\r
String password = mPasswordInput.getText().toString();\r
String remotePath ="";\r
boolean successIfAbsent = false;\r
boolean followRedirects = true;\r
- startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, username, password, followRedirects);\r
+ startExistenceCheckRemoteOperation(\r
+ remotePath, this, successIfAbsent, username, password, followRedirects);\r
\r
}\r
\r
- private void startExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent, String webdav_path,\r
+ private void startExistenceCheckRemoteOperation(\r
+ String remotePath, Context context, boolean successIfAbsent,\r
String username, String password, boolean followRedirects) {\r
Intent existenceCheckIntent = new Intent();\r
existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK);\r
existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mServerInfo.mBaseUrl);\r
existenceCheckIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);\r
existenceCheckIntent.putExtra(OperationsService.EXTRA_SUCCESS_IF_ABSENT, successIfAbsent);\r
- existenceCheckIntent.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path);\r
existenceCheckIntent.putExtra(OperationsService.EXTRA_USERNAME, username);\r
existenceCheckIntent.putExtra(OperationsService.EXTRA_PASSWORD, password);\r
existenceCheckIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN, mAuthToken);\r
IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);\r
dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);\r
\r
- /// get the path to the root folder through WebDAV from the version server\r
- String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);\r
-\r
/// test credentials accessing the root folder\r
String remotePath ="";\r
boolean successIfAbsent = false;\r
boolean followRedirections = false;\r
- startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirections);\r
+ startExistenceCheckRemoteOperation(\r
+ remotePath, this, successIfAbsent, "", "", followRedirections);\r
\r
}\r
\r
mWaitingForOpId = Long.MAX_VALUE;\r
dismissDialog(WAIT_DIALOG_TAG);\r
\r
- String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);\r
- if (result.isSuccess() && webdav_path != null) {\r
+ if (result.isSuccess()) {\r
/// be gentle with the user\r
IndeterminateProgressDialog dialog = \r
IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);\r
String remotePath ="";\r
boolean successIfAbsent = false;\r
boolean followRedirects = true;\r
- startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirects);\r
+ startExistenceCheckRemoteOperation(\r
+ remotePath, this, successIfAbsent, "", "", followRedirects);\r
\r
} else {\r
updateAuthStatusIconAndText(result);\r
String username = mUsernameInput.getText().toString().trim();\r
if (isOAuth) {\r
username = "OAuth_user" + (new java.util.Random(System.currentTimeMillis())).nextLong();\r
- } \r
- String accountName = username + "@" + uri.getHost();\r
- if (uri.getPort() >= 0) {\r
- accountName += ":" + uri.getPort();\r
}\r
+ String accountName = com.owncloud.android.lib.common.accounts.AccountUtils.\r
+ buildAccountName(uri, username);\r
Account newAccount = new Account(accountName, MainApp.getAccountType());\r
if (AccountUtils.exists(newAccount, getApplicationContext())) {\r
// fail - not a new account, but an existing one; disallow\r
if (mWaitingForOpId <= Integer.MAX_VALUE) {\r
mOperationsServiceBinder.dispatchResultIfFinished((int)mWaitingForOpId, this);\r
}\r
+ \r
+ if (mPendingAutoCheck) {\r
+ checkOcServer();\r
+ }\r
}\r
\r
\r