Browse Source

Adapted code to URIs refactoring in OwnCloudClient

David A. Velasco 10 years ago
parent
commit
7958161d25

+ 1 - 1
owncloud-android-library

@@ -1 +1 @@
-Subproject commit e069a8cb9f4f874ee91d7c012c083899556378e9
+Subproject commit 45aba26a47911184e286bd4d240c4c02d68fce9a

+ 9 - 13
src/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -828,9 +828,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * the root folder of the ownCloud server.
      */
     private void checkBasicAuthorization() {
-        /// get the path to the root folder through WebDAV from the version server
-        String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);
-
         /// get basic credentials entered by user
         String username = mUsernameInput.getText().toString();
         String password = mPasswordInput.getText().toString();
@@ -844,18 +841,19 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         String remotePath ="";
         boolean successIfAbsent = false;
         boolean followRedirects = true;
-        startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, username, password, followRedirects);
+        startExistenceCheckRemoteOperation(
+                remotePath, this, successIfAbsent, username, password, followRedirects);
         
     }
 
-    private void startExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent, String webdav_path,
+    private void startExistenceCheckRemoteOperation(
+            String remotePath, Context context, boolean successIfAbsent,
             String username, String password, boolean followRedirects) {
         Intent existenceCheckIntent = new Intent();
         existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK);
         existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mServerInfo.mBaseUrl);
         existenceCheckIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);
         existenceCheckIntent.putExtra(OperationsService.EXTRA_SUCCESS_IF_ABSENT, successIfAbsent);
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path);
         existenceCheckIntent.putExtra(OperationsService.EXTRA_USERNAME, username);
         existenceCheckIntent.putExtra(OperationsService.EXTRA_PASSWORD, password);
         existenceCheckIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN, mAuthToken);
@@ -904,14 +902,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);
         dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);
 
-        /// get the path to the root folder through WebDAV from the version server
-        String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);
-
         /// test credentials accessing the root folder
         String remotePath ="";
         boolean successIfAbsent = false;
         boolean followRedirections = false;
-        startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirections);
+        startExistenceCheckRemoteOperation(
+                remotePath, this, successIfAbsent, "", "", followRedirections);
 
     }
 
@@ -1284,8 +1280,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         mWaitingForOpId = Long.MAX_VALUE;
         dismissDialog(WAIT_DIALOG_TAG);
 
-        String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);
-        if (result.isSuccess() && webdav_path != null) {
+        if (result.isSuccess()) {
             /// be gentle with the user
             IndeterminateProgressDialog dialog = 
                     IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);
@@ -1301,7 +1296,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             String remotePath ="";
             boolean successIfAbsent = false;
             boolean followRedirects = true;
-            startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirects);
+            startExistenceCheckRemoteOperation(
+                    remotePath, this, successIfAbsent, "", "", followRedirects);
 
         } else {
             updateAuthStatusIconAndText(result);

+ 3 - 3
src/com/owncloud/android/operations/DetectAuthenticationMethodOperation.java

@@ -93,15 +93,15 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
         AuthenticationMethod authMethod = AuthenticationMethod.UNKNOWN;
         
         RemoteOperation operation = new ExistenceCheckRemoteOperation("", mContext, false);
-        client.setWebdavUri(Uri.parse(mWebDavUrl));
         client.clearCredentials();
         client.setFollowRedirects(false);
         
         // try to access the root folder, following redirections but not SAML SSO redirections
         result = operation.execute(client);
         String redirectedLocation = result.getRedirectedLocation(); 
-        while (redirectedLocation != null && redirectedLocation.length() > 0 && !result.isIdPRedirection()) {
-            client.setWebdavUri(Uri.parse(result.getRedirectedLocation()));
+        while (redirectedLocation != null && redirectedLocation.length() > 0 && 
+                !result.isIdPRedirection()) {
+            client.setBaseUri(Uri.parse(result.getRedirectedLocation()));
             result = operation.execute(client);
             redirectedLocation = result.getRedirectedLocation();
         } 

+ 2 - 2
src/com/owncloud/android/operations/GetServerInfoOperation.java

@@ -87,9 +87,9 @@ public class GetServerInfoOperation extends RemoteOperation {
 	protected RemoteOperationResult run(OwnCloudClient client) {
 	    
 	    // first: check the status of the server (including its version)
-	    GetRemoteStatusOperation getStatus = new GetRemoteStatusOperation(mUrl, mContext);
+	    GetRemoteStatusOperation getStatus = new GetRemoteStatusOperation(mContext);
 	    RemoteOperationResult result = getStatus.execute(client);
-
+	    
         if (result.isSuccess()) {
             // second: get authentication method required by the server
             mResultData.mVersion = (OwnCloudVersion)(result.getData().get(0));

+ 1 - 11
src/com/owncloud/android/services/OperationsService.java

@@ -80,7 +80,6 @@ public class OperationsService extends Service {
     public static final String EXTRA_RESULT = "RESULT";
     
     // TODO review if ALL OF THEM are necessary
-    public static final String EXTRA_WEBDAV_PATH = "WEBDAV_PATH";
     public static final String EXTRA_SUCCESS_IF_ABSENT = "SUCCESS_IF_ABSENT";
     public static final String EXTRA_USERNAME = "USERNAME";
     public static final String EXTRA_PASSWORD = "PASSWORD";
@@ -112,18 +111,16 @@ public class OperationsService extends Service {
     private static class Target {
         public Uri mServerUrl = null;
         public Account mAccount = null;
-        public String mWebDavUrl = null;
         public String mUsername = null;
         public String mPassword = null;
         public String mAuthToken = null;
         public boolean mFollowRedirects = true;
         public String mCookie = null;
         
-        public Target(Account account, Uri serverUrl, String webdavUrl, String username, String password, String authToken,
+        public Target(Account account, Uri serverUrl, String username, String password, String authToken,
                 boolean followRedirects, String cookie) {
             mAccount = account;
             mServerUrl = serverUrl;
-            mWebDavUrl = webdavUrl;
             mUsername = username;
             mPassword = password;
             mAuthToken = authToken;
@@ -303,8 +300,6 @@ public class OperationsService extends Service {
                 } else {
                     Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT);
                     String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL);
-                    String webDavPath = operationIntent.getStringExtra(EXTRA_WEBDAV_PATH);
-                    String webDavUrl = serverUrl + webDavPath;
                     String username = operationIntent.getStringExtra(EXTRA_USERNAME);
                     String password = operationIntent.getStringExtra(EXTRA_PASSWORD);
                     String authToken = operationIntent.getStringExtra(EXTRA_AUTH_TOKEN);
@@ -313,7 +308,6 @@ public class OperationsService extends Service {
                     target = new Target(
                             account, 
                             (serverUrl == null) ? null : Uri.parse(serverUrl),
-                            ((webDavPath == null) || (serverUrl == null)) ? null : webDavUrl,
                             username,
                             password,
                             authToken,
@@ -504,10 +498,6 @@ public class OperationsService extends Service {
                                         mLastTarget.mServerUrl,
                                         credentials,    // still can be null, and that is right
                                         this);
-                        
-                        if (mLastTarget.mWebDavUrl != null) {
-                            mOwnCloudClient.setWebdavUri(Uri.parse(mLastTarget.mWebDavUrl));
-                        }
                         mOwnCloudClient.setFollowRedirects(mLastTarget.mFollowRedirects);
                         mStorageManager = null;
                     }