Server or connection errors in authorization require handled as in server check
authorDavid A. Velasco <dvelasco@solidgear.es>
Mon, 10 Jun 2013 10:51:48 +0000 (12:51 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Mon, 10 Jun 2013 10:51:48 +0000 (12:51 +0200)
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/operations/RemoteOperationResult.java

index 919a40a..c1ca605 100644 (file)
@@ -906,7 +906,33 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
             finish();\r
 \r
-        } else {\r
+        } else if (result.isServerFail() || result.isException()) {\r
+            /// if server fail or exception in authorization, the UI is updated as when a server check failed\r
+            mServerIsChecked = true;\r
+            mServerIsValid = false;\r
+            mIsSslConn = false;\r
+            mOcServerChkOperation = null;\r
+            mDiscoveredVersion = null;\r
+            mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
+\r
+            // update status icon and text\r
+            updateServerStatusIconAndText(result);\r
+            showServerStatus();\r
+            mAuthStatusIcon = 0;\r
+            mAuthStatusText = 0;\r
+            showAuthStatus();\r
+            \r
+            // update input controls state\r
+            showRefreshButton();\r
+            mOkButton.setEnabled(false);\r
+\r
+            // very special case (TODO: move to a common place for all the remote operations) (dangerous here?)\r
+            if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {\r
+                mLastSslUntrustedServerResult = result;\r
+                showDialog(DIALOG_SSL_VALIDATOR); \r
+            }\r
+\r
+        } else {    // authorization fail due to client side - probably wrong credentials\r
             updateAuthStatusIconAndText(result);\r
             showAuthStatus();\r
             Log_OC.d(TAG, "Access failed: " + result.getLogMessage());\r
index 16b4779..059c290 100644 (file)
@@ -267,4 +267,12 @@ public class RemoteOperationResult implements Serializable {
 
     }
 
+    public boolean isServerFail() {
+        return (mHttpCode >= HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
+
+    public boolean isException() {
+        return (mException != null);
+    }
+
 }