X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/565875d7536a38de93eb30dd60733f01b231beda..281212045672b8439f09e50896d90a1f5c7524f1:/src/com/owncloud/android/authentication/AuthenticatorActivity.java diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 6ff9f6a7..cf768833 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -187,8 +187,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private boolean mResumed; // Control if activity is resumed public static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT"; - - private DetectAuthenticationMethodOperation mDetectAuthenticationOperation; + + private ServiceConnection mOperationsServiceConnection = null; + + private OperationsServiceBinder mOperationsServiceBinder = null; /** @@ -430,6 +432,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { return false; } }); + + mOperationsServiceConnection = new OperationsServiceConnection(); + bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE); } @@ -513,7 +518,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { // refresh button enabled outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE)); - } @@ -533,7 +537,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } } - /** * The redirection triggered by the OAuth authentication server as response to the GET AUTHORIZATION, and * deferred in {@link #onNewIntent(Intent)}, is processed here. @@ -1009,14 +1012,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private void detectAuthorizationMethod() { Log_OC.d(TAG, "Trying empty authorization to detect authentication method"); - - /// get the path to the root folder through WebDAV from the version server + String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType); - + /// test credentials - mDetectAuthenticationOperation = new DetectAuthenticationMethodOperation(this); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true); - mOperationThread = mDetectAuthenticationOperation.execute(client, this, mHandler); + Intent service = new Intent(this, OperationsService.class); + service.setAction(OperationsService.ACTION_DETECT_AUTHENTICATION_METHOD); + service.putExtra(OperationsService.EXTRA_SERVER_URL, mHostBaseUrl); + service.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path); + startService(service); } @@ -1842,4 +1846,31 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } + /** + * Implements callback methods for service binding. Passed as a parameter to { + */ + private class OperationsServiceConnection implements ServiceConnection { + + @Override + public void onServiceConnected(ComponentName component, IBinder service) { + if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) { + Log_OC.d(TAG, "Operations service connected"); + mOperationsServiceBinder = (OperationsServiceBinder) service; + mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler); + } else { + return; + } + + } + + @Override + public void onServiceDisconnected(ComponentName component) { + if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) { + Log_OC.d(TAG, "Operations service disconnected"); + mOperationsServiceBinder = null; + // TODO whatever could be waiting for the service is unbound + } + } + + } }