From: masensio Date: Tue, 25 Jun 2013 13:16:25 +0000 (-0700) Subject: Merge pull request #195 from owncloud/fixed_crash_due_to_uploads_to_accounts_not_alre... X-Git-Tag: oc-android-1.4.3~14 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/2402e9ed4cdb6857c8d245ba652dfcb7bb88d120?ds=inline;hp=-c Merge pull request #195 from owncloud/fixed_crash_due_to_uploads_to_accounts_not_already_existing Fixed crash due to uploads to accounts not already existing --- 2402e9ed4cdb6857c8d245ba652dfcb7bb88d120 diff --combined src/com/owncloud/android/authentication/AuthenticatorActivity.java index 3c34be61,32ab860c..51185520 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@@ -18,7 -18,6 +18,6 @@@ package com.owncloud.android.authentication; - import com.owncloud.android.AccountUtils; import com.owncloud.android.Log_OC; import com.owncloud.android.ui.dialog.SslValidatorDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener; @@@ -935,33 -934,7 +934,33 @@@ implements OnRemoteOperationListener, finish(); - } else { + } else if (result.isServerFail() || result.isException()) { + /// if server fail or exception in authorization, the UI is updated as when a server check failed + mServerIsChecked = true; + mServerIsValid = false; + mIsSslConn = false; + mOcServerChkOperation = null; + mDiscoveredVersion = null; + mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString()); + + // update status icon and text + updateServerStatusIconAndText(result); + showServerStatus(); + mAuthStatusIcon = 0; + mAuthStatusText = 0; + showAuthStatus(); + + // update input controls state + showRefreshButton(); + mOkButton.setEnabled(false); + + // very special case (TODO: move to a common place for all the remote operations) (dangerous here?) + if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) { + mLastSslUntrustedServerResult = result; + showDialog(DIALOG_SSL_VALIDATOR); + } + + } else { // authorization fail due to client side - probably wrong credentials updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); diff --combined src/com/owncloud/android/operations/RemoteOperationResult.java index 059c2908,6f4f2910..1fc01799 --- a/src/com/owncloud/android/operations/RemoteOperationResult.java +++ b/src/com/owncloud/android/operations/RemoteOperationResult.java @@@ -32,7 -32,11 +32,11 @@@ import org.apache.commons.httpclient.Ht import org.apache.commons.httpclient.HttpStatus; import org.apache.jackrabbit.webdav.DavException; + import android.accounts.Account; + import android.accounts.AccountsException; + import com.owncloud.android.Log_OC; + import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException; import com.owncloud.android.network.CertificateCombinedException; /** @@@ -47,6 -51,7 +51,7 @@@ public class RemoteOperationResult impl /** Generated - should be refreshed every time the class changes!! */ private static final long serialVersionUID = -7805531062432602444L; + private static final String TAG = "RemoteOperationResult"; @@@ -77,7 -82,9 +82,9 @@@ LOCAL_STORAGE_NOT_MOVED, LOCAL_STORAGE_NOT_COPIED, OAUTH2_ERROR_ACCESS_DENIED, - QUOTA_EXCEEDED + QUOTA_EXCEEDED, + ACCOUNT_NOT_FOUND, + ACCOUNT_EXCEPTION } private boolean mSuccess = false; @@@ -142,6 -149,12 +149,12 @@@ } else if (e instanceof UnknownHostException) { mCode = ResultCode.HOST_NOT_AVAILABLE; + } else if (e instanceof AccountNotFoundException) { + mCode = ResultCode.ACCOUNT_NOT_FOUND; + + } else if (e instanceof AccountsException) { + mCode = ResultCode.ACCOUNT_EXCEPTION; + } else if (e instanceof SSLException || e instanceof RuntimeException) { CertificateCombinedException se = getCertificateCombinedException(e); if (se != null) { @@@ -242,6 -255,13 +255,13 @@@ } else if (mException instanceof IOException) { return "Unrecovered transport exception"; + } else if (mException instanceof AccountNotFoundException) { + Account failedAccount = ((AccountNotFoundException)mException).getFailedAccount(); + return mException.getMessage() + " (" + (failedAccount != null ? failedAccount.name : "NULL") + ")"; + + } else if (mException instanceof AccountsException) { + return "Exception while using account"; + } else { return "Unexpected exception"; } @@@ -267,12 -287,4 +287,12 @@@ } + public boolean isServerFail() { + return (mHttpCode >= HttpStatus.SC_INTERNAL_SERVER_ERROR); + } + + public boolean isException() { + return (mException != null); + } + }