From: David A. Velasco Date: Tue, 1 Apr 2014 13:17:33 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/operations_service' into operations_service X-Git-Tag: oc-android-1.7.0_signed~345^2~14 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/e566d041d199b3a91bfcca7cda72160d7d4ddf8e?hp=0addc90ae5082de926dc9c5bbb8092d6efe123a8 Merge remote-tracking branch 'origin/operations_service' into operations_service --- diff --git a/owncloud-android-library b/owncloud-android-library index a3683116..6b69b5af 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit a3683116ae04f639ff39484b1c54788bbce9fd30 +Subproject commit 6b69b5af1a79275a23339ad6382210d75b061f9f diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index cfd46d55..e5a83f23 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -97,6 +97,7 @@ Τα περιεχόμενα των %1$d αρχείων δεν μπόρεσαν να συγχρονιστούν (%2$d διενέξεις) Ορισμένα τοπικά αρχεία ξεχάστηκαν %1$d αρχεια απο τον %2$s χωρο αποθηκευσης δεν μπορουν να αντιγραφθουν σε + Από την έκδοση 1.3.16 και μετά, αρχεία που μεταφορτώνονται από αυτήν τη συσκευή αντιγράφονται στον τοπικό φάκελο %1$s για να αποτραπεί η απώλεια δεδομένων όταν ένα αρχείο είναι συγχρονισμένο με πολλαπλούς λογαριασμούς.\nΛόγω αυτής της αλλαγής, όλα τα αρχεία που μεταφορτώθηκαν με προηγούμενες εκδόσεις αυτής της εφαρμογής αντιγράφηκαν στον φάκελο %2$s. Ωστόσο, ένα σφάλμα εμπόδισε την ολοκλήρωση αυτής της εργασίας κατά το συγχρονισμό του λογαριασμού. Μπορείτε είτε να αφήσετε τα αρχεία όπως είναι και να καταργήσετε την σύνδεση με το %3$s ή να μετακινήσετε τα αρχεία στον κατάλογο %1$s και να διατηρήσετε τη σύνδεση με το %4$s.\n\nΑπαριθμημένα πιο κάτω είναι το/τα τοπικό/ά αρχείο/α και το/τα απομακρυσμένο/α αρχείο/α στο %5$s με το/τα οποίο/α συνδέονταν. Ο φάκελος %1$s δεν υπάρχει πια Μετακινηση ολων Ολα τα αρχεια μετακινηθηκαν @@ -160,6 +161,8 @@ Σύνδεση με το διακομιστή πιστοποίησης σε εξέλιξη... Ο διακομιστής δεν υποστηρίζει αυτή τη μέθοδο πιστοποίησης Ο %1$s δεν υποστηρίζει πολλαπλούς λογαριασμούς + Ο διακομιστής σας δεν επιστρέφει το σωστό χαρακτηριστικό χρήστη, παρακαλώ επικοινωνήστε με έναν διαχειριστή + Δεν είναι δυνατός ο έλεγχος ταυτότητας με αυτόν τον διακομιστή Διατήρηση αρχείου ενημερωμένo Μετονομασία Αφαίρεση @@ -232,6 +235,7 @@ διαγραφή όλων των επιλεγμένων από τη λίστα προς μεταφόρτωση επανάληψη προσπάθειας μεταφόρτωσης της εικόνας: Φόρτωση περισσότερων εικόνων + μην κάνετε τίποτε, δεν είστε συνδεμένος για άμεση μεταφόρτωση Μήνυμα Αποτυχίας: Παρακαλώ ελέγξτε τις ρυθμίσεις του διακομιστή σας, ίσως έχετε υπερβεί τη διαθέσιμη μερίδα σας. Λυπάμαι, ο διαμοιρασμός δεν είναι ενεργοποιημένος στο διακομιστή σας. Παρακαλώ επικοινωνήστε με το διαχειριστή σας. diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index ae55740f..7778364f 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -28,7 +28,7 @@ Recomendar a un amigo Mensajes de retroalimentación Imprint - Prueba %1$s en tu smarthphone! + ¡Prueba %1$s en tu teléfono inteligente! Quiero invitarte a usar %1$s en tu smarthphone!⏎\nDescargalo aquí: %2$s Compruebe el servidor. Dirección del servidor https://… @@ -94,14 +94,14 @@ Se encontraron conflictos Falló la sincronización de contenidos de %1$d ficheros Fallos en la sincronización de contenidos - Los contenidos de %1$d ficheros no fueron sincronizados (%2$d conflictos) + Los contenidos de %1$d ficheros no se han sincronizado (%2$d conflictos) Algunos archivos locales se han perdido %1$d archivos de %2$s no han podido ser copiados Como en la versión 1.3.16, los archivos subidos de este dispositivo son copiados a una carpeta local %1$s para evitar la perdida de datos cuando un unico archivo es sincronizado desde multiples cuentas\n\nDebido a este cambio, todos los archivos subidos en versiones previas de esta aplicación han sido copiados a la carpeta %2$s. No obtante, un error evito el completado de esta operación durante la sincronización de cuenta. Debería dejar el o los archivos así y eliminar el enlace a %3$s o mover el o los archivos al %1$s directorio y conservar el enlace a %4$s.\n\n Abajo tiene listado los enlaces a los archivos locales y archivos remotos en %5$s . La carpeta local %1$s no existe. Mover todo Todos los archivos fueron movidos - Algunos archivos no han podido ser movidos + No se han podido mover algunos archivos Local: %1$s Remoto: %1$s No hay suficiente espacio para copiar los archivos seleccionados en la carpeta %1$s. ¿Quiere moverlos en lugar de copiarlos? @@ -157,17 +157,17 @@ Estado inesperado; por favor, introduzca la URL del servidor de nuevo Su autorización ha expirado. Por favor, autorice de nuevo Por favor, introduzca la contraseña actual. - Su sesión ha expirado. Favor de conectarse de nuevo + Tu sesión ha expirado. Por favor, intenta conectarte de nuevo Conectando al servidor de autenticación... El servidor no soporta este método de autenticación %1$s no soporta cuentas múltiples - Su servidor no está retornando una identificación de usuario correcta. Contacte a un administrador. + Su servidor no está retornando una identificación de usuario correcta. Contacte con el administrador. No puede autenticarse en este servidor. Mantener el archivo actualizado Renombrar Borrar ¿Está seguro que desea borrar %1$s ? - ¿Desea elimiar %1$s y sus descendientes? + ¿Desea eliminar %1$s y sus descendientes? Sólo local Sólo ficheros locales Eliminar del servidor @@ -177,7 +177,7 @@ Introduzca un nombre nuevo No se pudo cambiar el nombre de la copia local, trata con un nombre differente No se pudo cambiar el nombre - No pudo comprobarse el fichero remoto + No se ha podido comprobar el fichero remoto Ya está sincronizado El directorio no pudo ser creado Carácteres ilegales: / \\ < > : \" | ? * @@ -201,7 +201,7 @@ Nombre común: Organización: Unidad organizativa - Pais: + País: Estado: Ubicación: Validez: @@ -209,7 +209,7 @@ A: Firma: Algoritmo: - El certifiicado no pudo ser mostrado. + No se ha podido mostrar el certificado - No hay información acerca del error Esto es un marcador de posición marcadordeposición.txt @@ -238,7 +238,7 @@ No hacer nada no está conectado para subida instantánea Mensaje de error: Por favor revise su configuración de servidor, posiblemente su cuota se haya excedido. - Compartir archivos no está activado en su servidor. Sírvase contactar a su administrador de sistema. + Compartir archivos no está activado en tu servidor. Por favor, ponte en contacto con el administrador. No es posible compartir este archivo o carpeta. Asegúrese de que existe. Ocurrió un error al tratar de compartir este archivo o carpeta No se puede dejar de compartir este archivo o carpeta. No existe. diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml index 7d8a49a5..14ccc2cf 100644 --- a/res/values-gl/strings.xml +++ b/res/values-gl/strings.xml @@ -161,6 +161,7 @@ Conectando co servidor de autenticación… O servidor non admite este método de autenticación %1$s non admite contas múltipes + O seu servidor non devolveu un ID de usuario correcto, contacte cun administrador Non é posíbel autenticalo neste servidor Manter actualizado o ficheiro Renomear diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 737a6d9c..8a634215 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -161,7 +161,8 @@ Connessione al server di autenticazione in corso... Il server non supporta questo metodo di autenticazione %1$s non supporta account multipli - Impossibile eseguire l\'autenticazione su questo server. + Il tuo server non restituisce un id utente corretto, contatta un amministratore + Impossibile eseguire l\'autenticazione su questo server Tieni aggiornato il file Rinomina Rimuovi diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 39dde265..e2995314 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -161,6 +161,7 @@ Łączenie z serwerem autoryzacji... Serwer nie obsługuje tej metody autoryzacji %1$s nie wspiera multikont + Twój serwer nie zwraca prawidłowego identyfikatora użytkownika, proszę skontaktuj się z administratorem Nie można autoryzować z tym serwerem Automatyczne aktualizuj plik Zmień nazwę diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 505cfa54..fc99385a 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -97,6 +97,7 @@ Vsebine %1$d datotek ni bilo mogoče uskladiti (zaznanih je %2$d sporov) Nekatere krajevne datoteke so spregledane Skupno %1$d datotek iz mape %2$s ni mogoče kopirati v + Od različice 1.3.16 so datoteke, poslane iz te naprave, varnostno kopirane v krajevno mapo %1$s. S tem je preprečena izguba podatkov, ko je ena datoteka usklajena z več računi.\n\nZaradi te spremembe so vse datoteke, ki so bile kopirane v prejšnjih različicah, kopirane v mapo %2$s. Zaradi napake ni mogoče končati usklajevanja. Datoteke lahko ali pustite kjer so in odstranite povezavo na %3$s ali pa premaknete datoteke v mapo %1$s in ohranite povezavo do %4$s.\n\nSpodaj so izpisane krajevne datoteke in oddaljene povezane datoteke v mapi %5$s. Mapa %1$s ne obstaja več Premakni vse Vse datoteke so uspešno premaknjene na novo mesto @@ -160,6 +161,8 @@ Poteka povezovanje z overitvenim strežnikom ... Strežnik ne podpira tega načina overitve %1$s ne omogoča podpore več računom + Strežnik ne vrača ustreznega ID uporabnika. Stopite v stik s skrbnikom sistema. + S tem strežnikom overitev ni mogoča Datoteka naj bo posodobljena Preimenuj Odstrani diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 84362ba9..fc1e3982 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -111,7 +111,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private static final String KEY_AUTH_MESSAGE_TEXT = "AUTH_MESSAGE_TEXT"; private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT"; private static final String KEY_OC_VERSION = "OC_VERSION"; - private static final String KEY_OC_VERSION_STRING = "OC_VERSION_STRING"; private static final String KEY_ACCOUNT = "ACCOUNT"; private static final String KEY_SERVER_VALID = "SERVER_VALID"; private static final String KEY_SERVER_CHECKED = "SERVER_CHECKED"; @@ -157,10 +156,11 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private final Handler mHandler = new Handler(); private Thread mOperationThread; - //private GetRemoteStatusOperation mOcServerChkOperation; private GetServerInfoOperation mServerInfoOperation; - private ExistenceCheckRemoteOperation mAuthCheckOperation; + //private ExistenceCheckRemoteOperation mAuthCheckOperation; + private int mExistenceCheckOpId = -1; + private Uri mNewCapturedUriFromOAuth2Redirection; private AccountManager mAccountMgr; @@ -281,10 +281,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// retrieve extras from intent mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT); if (mAccount != null) { - String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); - String ocVersionString = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION_STRING); + String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); if (ocVersion != null) { - mDiscoveredVersion = new OwnCloudVersion(ocVersion, ocVersionString); + mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = normalizeUrl(mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL)); mHostUrlInput.setText(mHostBaseUrl); @@ -317,9 +316,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// server data String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); - String ocVersionString = savedInstanceState.getString(KEY_OC_VERSION_STRING); if (ocVersion != null) { - mDiscoveredVersion = new OwnCloudVersion(ocVersion, ocVersionString); + mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); @@ -500,7 +498,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// server data if (mDiscoveredVersion != null) { outState.putString(KEY_OC_VERSION, mDiscoveredVersion.getVersion()); - outState.putString(KEY_OC_VERSION_STRING, mDiscoveredVersion.getVersionString()); } outState.putString(KEY_HOST_URL_TEXT, mHostBaseUrl); @@ -827,12 +824,32 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { showDialog(DIALOG_LOGIN_PROGRESS); /// test credentials accessing the root folder - mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true); - client.setBasicCredentials(username, password); - mOperationThread = mAuthCheckOperation.execute(client, this, mHandler); + String remotePath =""; + boolean successIfAbsent = false; + boolean followRedirects = true; + startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, username, password, followRedirects); + } + private void startExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent, String webdav_path, + String username, String password, boolean followRedirects) { + + Intent existenceCheckIntent = new Intent(); + existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK); + existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mHostBaseUrl); + existenceCheckIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath); + existenceCheckIntent.putExtra(OperationsService.EXTRA_SUCCESS_IF_ABSENT, successIfAbsent); + existenceCheckIntent.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path); + existenceCheckIntent.putExtra(OperationsService.EXTRA_USERNAME, username); + existenceCheckIntent.putExtra(OperationsService.EXTRA_PASSWORD, password); + existenceCheckIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN, mAuthToken); + existenceCheckIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects); + + if (mOperationsServiceBinder != null) { + Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." ); + mExistenceCheckOpId = mOperationsServiceBinder.newOperation(existenceCheckIntent); + } + } /** * Starts the OAuth 'grant type' flow to get an access token, with @@ -875,9 +892,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType); /// test credentials accessing the root folder - mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false); - mOperationThread = mAuthCheckOperation.execute(client, this, mHandler); + String remotePath =""; + boolean successIfAbsent = false; + boolean followRedirections = false; + startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirections); } @@ -899,11 +917,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { onGetOAuthAccessTokenFinish(result); } else if (operation instanceof ExistenceCheckRemoteOperation) { + Log_OC.wtf(TAG, "received detection response through callback" ); if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) { - onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result); + onSamlBasedFederatedSingleSignOnAuthorizationStart(result); } else { - onAuthorizationCheckFinish((ExistenceCheckRemoteOperation)operation, result); + onAuthorizationCheckFinish(result); } } else if (operation instanceof GetRemoteUserNameOperation) { onGetUserNameFinish((GetRemoteUserNameOperation) operation, result); @@ -945,7 +964,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } - private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperation operation, RemoteOperationResult result) { + private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) { + mExistenceCheckOpId = -1; try { dismissDialog(DIALOG_LOGIN_PROGRESS); } catch (IllegalArgumentException e) { @@ -1053,8 +1073,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { url = "http://" + url; } } - - // OC-208: Add suffix remote.php/webdav to normalize (OC-34) + url = trimUrlWebdav(url); if (url.endsWith("/")) { @@ -1274,10 +1293,11 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mAuthToken = tokens.get(OAuth2Constants.KEY_ACCESS_TOKEN); //mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN); Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken); - mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true); - client.setBearerCredentials(mAuthToken); - mAuthCheckOperation.execute(client, this, mHandler); + + String remotePath =""; + boolean successIfAbsent = false; + boolean followRedirects = true; + startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirects); } else { updateAuthStatusIconAndText(result); @@ -1295,7 +1315,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { * @param operation Access check performed. * @param result Result of the operation. */ - private void onAuthorizationCheckFinish(ExistenceCheckRemoteOperation operation, RemoteOperationResult result) { + private void onAuthorizationCheckFinish(RemoteOperationResult result) { + mExistenceCheckOpId = -1; try { dismissDialog(DIALOG_LOGIN_PROGRESS); } catch (IllegalArgumentException e) { @@ -1442,7 +1463,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } /// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mDiscoveredVersion.getVersion()); - mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION_STRING, mDiscoveredVersion.getVersionString()); mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mHostBaseUrl); if (isSaml) { @@ -1877,7 +1897,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { RemoteOperationResult result = mOperationsServiceBinder.getOperationResultIfFinished(mGetServerInfoOpId); if (result != null) { - //Log.wtf(TAG, "found result of operation finished while rotating"); + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); onGetServerInfoFinish(result); } @@ -1886,9 +1906,23 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mOperationsServiceBinder.getOperationResultIfFinished( mOauth2GetAccessTokenOpId); if (result != null) { - //Log.wtf(TAG, "found result of operation finished while rotating"); + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); onGetOAuthAccessTokenFinish(result); } + + } else if (mExistenceCheckOpId != -1) { + RemoteOperationResult result = + mOperationsServiceBinder.getOperationResultIfFinished(mExistenceCheckOpId); + if (result != null) { + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); + if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie( + MainApp.getAccountType()).equals(mAuthTokenType)) { + onSamlBasedFederatedSingleSignOnAuthorizationStart(result); + + } else { + onAuthorizationCheckFinish(result); + } + } } } diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index 5b74dc89..5d500072 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -139,8 +139,7 @@ public class FileOperationsHelper { AccountManager accountManager = AccountManager.get(callerActivity); String version = accountManager.getUserData(callerActivity.getAccount(), Constants.KEY_OC_VERSION); - String versionString = accountManager.getUserData(callerActivity.getAccount(), Constants.KEY_OC_VERSION_STRING); - return (new OwnCloudVersion(version, versionString)).isSharedSupported(); + return (new OwnCloudVersion(version)).isSharedSupported(); //return Boolean.parseBoolean(accountManager.getUserData(callerActivity.getAccount(), OwnCloudAccount.Constants.KEY_SUPPORTS_SHARE_API)); } return false; diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 557df658..9d2b4fa8 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -253,8 +253,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe AccountManager aMgr = AccountManager.get(this); String version = aMgr.getUserData(account, Constants.KEY_OC_VERSION); - String versionString = aMgr.getUserData(account, Constants.KEY_OC_VERSION_STRING); - OwnCloudVersion ocv = new OwnCloudVersion(version, versionString); + OwnCloudVersion ocv = new OwnCloudVersion(version); boolean chunked = FileUploader.chunkedUploadIsSupported(ocv); AbstractList requestedUploads = new Vector(); diff --git a/src/com/owncloud/android/operations/UpdateOCVersionOperation.java b/src/com/owncloud/android/operations/UpdateOCVersionOperation.java index c878ede4..ddcd52c6 100644 --- a/src/com/owncloud/android/operations/UpdateOCVersionOperation.java +++ b/src/com/owncloud/android/operations/UpdateOCVersionOperation.java @@ -78,11 +78,9 @@ public class UpdateOCVersionOperation extends RemoteOperation { if (json != null && json.getString("version") != null) { String version = json.getString("version"); - String versionstring = json.getString("versionstring"); - mOwnCloudVersion = new OwnCloudVersion(version, versionstring); + mOwnCloudVersion = new OwnCloudVersion(version); if (mOwnCloudVersion.isVersionValid()) { accountMngr.setUserData(mAccount, Constants.KEY_OC_VERSION, mOwnCloudVersion.getVersion()); - accountMngr.setUserData(mAccount, Constants.KEY_OC_VERSION_STRING, mOwnCloudVersion.getVersionString()); Log_OC.d(TAG, "Got new OC version " + mOwnCloudVersion.toString()); result = new RemoteOperationResult(ResultCode.OK); diff --git a/src/com/owncloud/android/services/OperationsService.java b/src/com/owncloud/android/services/OperationsService.java index 42b46e80..f0f37f5c 100644 --- a/src/com/owncloud/android/services/OperationsService.java +++ b/src/com/owncloud/android/services/OperationsService.java @@ -30,6 +30,7 @@ import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.operations.OnRemoteOperationListener; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; +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; @@ -64,10 +65,19 @@ public class OperationsService extends Service { 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"; + public static final String EXTRA_PASSWORD = "PASSWORD"; + public static final String EXTRA_AUTH_TOKEN = "AUTH_TOKEN"; + public static final String EXTRA_FOLLOW_REDIRECTS = "FOLLOW_REDIRECTS"; + public static final String ACTION_CREATE_SHARE = "CREATE_SHARE"; public static final String ACTION_UNSHARE = "UNSHARE"; 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"; public static final String ACTION_OPERATION_FINISHED = OperationsService.class.getName() + ".OPERATION_FINISHED"; @@ -81,9 +91,21 @@ public class OperationsService extends Service { private static class Target { public Uri mServerUrl = null; public Account mAccount = null; - public Target(Account account, Uri serverUrl) { + public String mWebDavUrl = ""; + public String mUsername = ""; + public String mPassword = ""; + public String mAuthToken = ""; + public boolean mFollowRedirects = true; + + public Target(Account account, Uri serverUrl, String webdavUrl, String username, String password, String authToken, + boolean followRedirects) { mAccount = account; mServerUrl = serverUrl; + mWebDavUrl = webdavUrl; + mUsername = username; + mPassword = password; + mAuthToken = authToken; + mFollowRedirects = followRedirects; } } @@ -232,9 +254,20 @@ public class OperationsService extends Service { } else { Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT); String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL); + String webDavPath = operationIntent.getStringExtra(EXTRA_WEBDAV_PATH); + String webDavUrl = serverUrl + webDavPath; + String username = operationIntent.getStringExtra(EXTRA_USERNAME); + String password = operationIntent.getStringExtra(EXTRA_PASSWORD); + String authToken = operationIntent.getStringExtra(EXTRA_AUTH_TOKEN); + boolean followRedirects = operationIntent.getBooleanExtra(EXTRA_FOLLOW_REDIRECTS, true); target = new Target( account, - (serverUrl == null) ? null : Uri.parse(serverUrl) + (serverUrl == null) ? null : Uri.parse(serverUrl), + ((webDavPath == null) || (serverUrl == null)) ? "" : webDavUrl, + (username == null) ? "" : username, + (password == null) ? "" : password, + (authToken == null) ? "" : authToken, + followRedirects ); String action = operationIntent.getAction(); @@ -245,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) { @@ -252,6 +286,7 @@ public class OperationsService extends Service { remotePath, OperationsService.this); } + } else if (action.equals(ACTION_GET_SERVER_INFO)) { // check OC server and get basic information from it String authTokenType = @@ -268,6 +303,13 @@ public class OperationsService extends Service { 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); + boolean successIfAbsent = operationIntent.getBooleanExtra(EXTRA_SUCCESS_IF_ABSENT, true); + operation = new ExistenceCheckRemoteOperation(remotePath, OperationsService.this, successIfAbsent); + } } @@ -329,7 +371,7 @@ public class OperationsService extends Service { synchronized(mPendingOperations) { next = mPendingOperations.peek(); } - + if (next != null) { mCurrentOperation = next.second; @@ -342,7 +384,16 @@ public class OperationsService extends Service { mOwnCloudClient = OwnCloudClientFactory.createOwnCloudClient(mLastTarget.mAccount, getApplicationContext()); mStorageManager = new FileDataStorageManager(mLastTarget.mAccount, getContentResolver()); } else { - mOwnCloudClient = OwnCloudClientFactory.createOwnCloudClient(mLastTarget.mServerUrl, getApplicationContext(), true); // this is not good enough + mOwnCloudClient = OwnCloudClientFactory.createOwnCloudClient(mLastTarget.mServerUrl, getApplicationContext(), + mLastTarget.mFollowRedirects); // this is not good enough + if (mLastTarget.mWebDavUrl != "") { + mOwnCloudClient.setWebdavUri(Uri.parse(mLastTarget.mWebDavUrl)); + } + if (mLastTarget.mUsername != "" && mLastTarget.mPassword != "") { + mOwnCloudClient.setBasicCredentials(mLastTarget.mUsername, mLastTarget.mPassword); + } else if (mLastTarget.mAuthToken != "") { + mOwnCloudClient.setBearerCredentials(mLastTarget.mAuthToken); + } mStorageManager = null; } }