Using default singleton OwnCloudClientManager instead of holding a reference in appli...
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index 32bbcdc..fccd615 100644 (file)
@@ -828,9 +828,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * 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
@@ -844,18 +841,19 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         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
@@ -904,14 +902,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 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
@@ -1284,8 +1280,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         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
@@ -1301,7 +1296,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             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
@@ -1417,11 +1413,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         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