X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/c2c10bcff893790e7af07c51afeb43315ff2ed84..e566d041d199b3a91bfcca7cda72160d7d4ddf8e:/src/com/owncloud/android/services/OperationsService.java diff --git a/src/com/owncloud/android/services/OperationsService.java b/src/com/owncloud/android/services/OperationsService.java index d44a3af4..f0f37f5c 100644 --- a/src/com/owncloud/android/services/OperationsService.java +++ b/src/com/owncloud/android/services/OperationsService.java @@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; +import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.lib.common.OwnCloudClientFactory; import com.owncloud.android.lib.common.OwnCloudClient; @@ -33,7 +34,8 @@ import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.operations.common.SyncOperation; import com.owncloud.android.operations.CreateShareOperation; -import com.owncloud.android.operations.DetectAuthenticationMethodOperation; +import com.owncloud.android.operations.GetServerInfoOperation; +import com.owncloud.android.operations.OAuth2GetAccessToken; import com.owncloud.android.operations.UnshareLinkOperation; import com.owncloud.android.utils.Log_OC; @@ -57,9 +59,13 @@ public class OperationsService extends Service { public static final String EXTRA_ACCOUNT = "ACCOUNT"; public static final String EXTRA_SERVER_URL = "SERVER_URL"; + public static final String EXTRA_AUTH_TOKEN_TYPE = "AUTH_TOKEN_TYPE"; + public static final String EXTRA_OAUTH2_QUERY_PARAMETERS = "OAUTH2_QUERY_PARAMETERS"; public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH"; public static final String EXTRA_SEND_INTENT = "SEND_INTENT"; 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"; @@ -69,7 +75,8 @@ public class OperationsService extends Service { public static final String ACTION_CREATE_SHARE = "CREATE_SHARE"; public static final String ACTION_UNSHARE = "UNSHARE"; - public static final String ACTION_DETECT_AUTHENTICATION_METHOD = "DETECT_AUTHENTICATION_METHOD"; + public static final String ACTION_GET_SERVER_INFO = "GET_SERVER_INFO"; + public static final String ACTION_OAUTH2_GET_ACCESS_TOKEN = "OAUTH2_GET_ACCESS_TOKEN"; public static final String ACTION_EXISTENCE_CHECK = "EXISTENCE_CHECK"; public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() + ".OPERATION_ADDED"; @@ -271,6 +278,7 @@ public class OperationsService extends Service { operation = new CreateShareOperation(remotePath, ShareType.PUBLIC_LINK, "", false, "", 1, sendIntent); } + } else if (action.equals(ACTION_UNSHARE)) { // Unshare file String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); if (remotePath.length() > 0) { @@ -278,13 +286,24 @@ public class OperationsService extends Service { remotePath, OperationsService.this); } - } else if (action.equals(ACTION_DETECT_AUTHENTICATION_METHOD)) { - // Detect Authentication Method - String webdav_url = - serverUrl + operationIntent.getStringExtra(EXTRA_WEBDAV_PATH); - operation = new DetectAuthenticationMethodOperation( - OperationsService.this, - webdav_url); + + } else if (action.equals(ACTION_GET_SERVER_INFO)) { + // check OC server and get basic information from it + String authTokenType = + operationIntent.getStringExtra(EXTRA_AUTH_TOKEN_TYPE); + operation = new GetServerInfoOperation( + serverUrl, authTokenType, OperationsService.this); + + } else if (action.equals(ACTION_OAUTH2_GET_ACCESS_TOKEN)) { + /// GET ACCESS TOKEN to the OAuth server + String oauth2QueryParameters = + operationIntent.getStringExtra(EXTRA_OAUTH2_QUERY_PARAMETERS); + operation = new OAuth2GetAccessToken( + getString(R.string.oauth2_client_id), + getString(R.string.oauth2_redirect_uri), + getString(R.string.oauth2_grant_type), + oauth2QueryParameters); + } else if (action.equals(ACTION_EXISTENCE_CHECK)) { // Existence Check String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);