private static final String KEY_AUTH_MESSAGE_TEXT = "AUTH_MESSAGE_TEXT";\r
private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT";\r
private static final String KEY_OC_VERSION = "OC_VERSION";\r
- private static final String KEY_OC_VERSION_STRING = "OC_VERSION_STRING";\r
private static final String KEY_ACCOUNT = "ACCOUNT";\r
private static final String KEY_SERVER_VALID = "SERVER_VALID";\r
private static final String KEY_SERVER_CHECKED = "SERVER_CHECKED";\r
\r
private final Handler mHandler = new Handler();\r
private Thread mOperationThread;\r
- //private GetRemoteStatusOperation mOcServerChkOperation;\r
private GetServerInfoOperation mServerInfoOperation;\r
- private ExistenceCheckRemoteOperation mAuthCheckOperation;\r
\r
+ //private ExistenceCheckRemoteOperation mAuthCheckOperation;\r
+ private int mExistenceCheckOpId = -1;\r
+ \r
private Uri mNewCapturedUriFromOAuth2Redirection;\r
\r
private AccountManager mAccountMgr;\r
/// retrieve extras from intent\r
mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);\r
if (mAccount != null) {
- String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION);\r
- String ocVersionString = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION_STRING);
+ String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION);
if (ocVersion != null) {\r
- mDiscoveredVersion = new OwnCloudVersion(ocVersion, ocVersionString);\r
+ mDiscoveredVersion = new OwnCloudVersion(ocVersion);\r
}\r
mHostBaseUrl = normalizeUrl(mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL));\r
mHostUrlInput.setText(mHostBaseUrl);\r
\r
/// server data\r
String ocVersion = savedInstanceState.getString(KEY_OC_VERSION);\r
- String ocVersionString = savedInstanceState.getString(KEY_OC_VERSION_STRING);\r
if (ocVersion != null) {\r
- mDiscoveredVersion = new OwnCloudVersion(ocVersion, ocVersionString);\r
+ mDiscoveredVersion = new OwnCloudVersion(ocVersion);\r
}\r
mHostBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT);\r
\r
/// server data\r
if (mDiscoveredVersion != null) {\r
outState.putString(KEY_OC_VERSION, mDiscoveredVersion.getVersion());\r
- outState.putString(KEY_OC_VERSION_STRING, mDiscoveredVersion.getVersionString());\r
}\r
outState.putString(KEY_HOST_URL_TEXT, mHostBaseUrl);\r
\r
showDialog(DIALOG_LOGIN_PROGRESS);\r
\r
/// test credentials accessing the root folder\r
- mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false);\r
- OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
- client.setBasicCredentials(username, password);\r
- mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
+ String remotePath ="";\r
+ boolean successIfAbsent = false;\r
+ boolean followRedirects = true;\r
+ startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, username, password, followRedirects);\r
+ \r
}\r
\r
+ private void startExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent, String webdav_path,\r
+ String username, String password, boolean followRedirects) {\r
+ \r
+ Intent existenceCheckIntent = new Intent();\r
+ existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK);\r
+ existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mHostBaseUrl);\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
+ existenceCheckIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects);\r
+ \r
+ if (mOperationsServiceBinder != null) {\r
+ Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." );\r
+ mExistenceCheckOpId = mOperationsServiceBinder.newOperation(existenceCheckIntent);\r
+ }\r
+ }\r
\r
/**\r
* Starts the OAuth 'grant type' flow to get an access token, with \r
String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);\r
\r
/// test credentials accessing the root folder\r
- mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false);\r
- OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false);\r
- mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
+ String remotePath ="";\r
+ boolean successIfAbsent = false;\r
+ boolean followRedirections = false;\r
+ startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirections);\r
\r
}\r
\r
onGetOAuthAccessTokenFinish(result);\r
\r
} else if (operation instanceof ExistenceCheckRemoteOperation) {\r
+ Log_OC.wtf(TAG, "received detection response through callback" );\r
if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
- onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result);\r
+ onSamlBasedFederatedSingleSignOnAuthorizationStart(result);\r
\r
} else {\r
- onAuthorizationCheckFinish((ExistenceCheckRemoteOperation)operation, result);\r
+ onAuthorizationCheckFinish(result);\r
}\r
} else if (operation instanceof GetRemoteUserNameOperation) {\r
onGetUserNameFinish((GetRemoteUserNameOperation) operation, result);\r
\r
}\r
\r
- private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperation operation, RemoteOperationResult result) {\r
+ private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) {\r
+ mExistenceCheckOpId = -1;\r
try {\r
dismissDialog(DIALOG_LOGIN_PROGRESS);\r
} catch (IllegalArgumentException e) {\r
url = "http://" + url;\r
}\r
}\r
-\r
- // OC-208: Add suffix remote.php/webdav to normalize (OC-34) \r
+ \r
url = trimUrlWebdav(url);\r
\r
if (url.endsWith("/")) {\r
mAuthToken = tokens.get(OAuth2Constants.KEY_ACCESS_TOKEN);\r
//mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN);\r
Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);\r
- mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false);\r
- OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
- client.setBearerCredentials(mAuthToken);\r
- mAuthCheckOperation.execute(client, this, mHandler);\r
+ \r
+ String remotePath ="";\r
+ boolean successIfAbsent = false;\r
+ boolean followRedirects = true;\r
+ startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirects);\r
\r
} else {\r
updateAuthStatusIconAndText(result);\r
* @param operation Access check performed.\r
* @param result Result of the operation.\r
*/\r
- private void onAuthorizationCheckFinish(ExistenceCheckRemoteOperation operation, RemoteOperationResult result) {\r
+ private void onAuthorizationCheckFinish(RemoteOperationResult result) {\r
+ mExistenceCheckOpId = -1;\r
try {\r
dismissDialog(DIALOG_LOGIN_PROGRESS);\r
} catch (IllegalArgumentException e) {\r
}\r
/// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mDiscoveredVersion.getVersion());\r
- mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION_STRING, mDiscoveredVersion.getVersionString());\r
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mHostBaseUrl);\r
if (isSaml) {\r
RemoteOperationResult result = \r
mOperationsServiceBinder.getOperationResultIfFinished(mGetServerInfoOpId);\r
if (result != null) {\r
- //Log.wtf(TAG, "found result of operation finished while rotating");\r
+ //Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
onGetServerInfoFinish(result);\r
}\r
\r
mOperationsServiceBinder.getOperationResultIfFinished(\r
mOauth2GetAccessTokenOpId);\r
if (result != null) {\r
- //Log.wtf(TAG, "found result of operation finished while rotating");\r
+ //Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
onGetOAuthAccessTokenFinish(result);\r
}\r
+ \r
+ } else if (mExistenceCheckOpId != -1) {\r
+ RemoteOperationResult result = \r
+ mOperationsServiceBinder.getOperationResultIfFinished(mExistenceCheckOpId);\r
+ if (result != null) {\r
+ //Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
+ if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(\r
+ MainApp.getAccountType()).equals(mAuthTokenType)) {\r
+ onSamlBasedFederatedSingleSignOnAuthorizationStart(result);\r
+\r
+ } else {\r
+ onAuthorizationCheckFinish(result);\r
+ }\r
+ }\r
}\r
}\r
\r