X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/f991e1e91dce62fbf4b04c9687010a022b09e125..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 255ed801..cf768833 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -58,6 +58,7 @@ import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; +import android.widget.Toast; import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.MainApp; @@ -146,6 +147,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private int mAuthStatusText, mAuthStatusIcon; private TextView mAuthStatusLayout; + private ServiceConnection mOperationsConnection = null; + private OperationsServiceBinder mOperationsBinder = null; + private final Handler mHandler = new Handler(); private Thread mOperationThread; private GetRemoteStatusOperation mOcServerChkOperation; @@ -199,6 +203,32 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); + // bind to Operations Service + mOperationsConnection = new ServiceConnection() { + + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + Log_OC.d(TAG, "Operations service connected"); + mOperationsBinder = (OperationsServiceBinder) service; + } + + @Override + public void onServiceDisconnected(ComponentName name) { + Log_OC.d(TAG, "Operations service crashed"); + mOperationsBinder = null; + } + + }; + if (!bindService(new Intent(this, OperationsService.class), + mOperationsConnection, + Context.BIND_AUTO_CREATE)) { + Toast.makeText(this, + R.string.error_cant_bind_to_operations_service, + Toast.LENGTH_LONG) + .show(); + finish(); + } + /// set view and get references to view elements setContentView(R.layout.account_setup); mAuthMessage = (TextView) findViewById(R.id.auth_message); @@ -488,7 +518,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { // refresh button enabled outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE)); - } @@ -508,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. @@ -536,6 +564,16 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mJustCreated = false; } + + + @Override + protected void onDestroy() { + if (mOperationsConnection != null) { + unbindService(mOperationsConnection); + mOperationsBinder = null; + } + super.onDestroy(); + } /** @@ -974,11 +1012,14 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private void detectAuthorizationMethod() { Log_OC.d(TAG, "Trying empty authorization to detect authentication method"); - + + String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType); + /// test credentials - Intent service = new Intent(this, OperationsService.class); + 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); }