1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Compare commits

..

No commits in common. "master" and "2.1-beta.4" have entirely different histories.

19 changed files with 56 additions and 54 deletions

View File

@ -49,6 +49,6 @@ ownCloud Android Library uses OkHttp version 4.6.0, licensed under Apache Licens
### Compatibility ### Compatibility
ownCloud Android Library is valid for Android systems from version Android 6 (android:minSdkVersion="23" android:targetSdkVersion="33"). ownCloud Android Library is valid for Android systems from version Android 5 (android:minSdkVersion="21" android:targetSdkVersion="29").
ownCloud Android library supports ownCloud server from version 4.5. ownCloud Android library supports ownCloud server from version 4.5.

View File

@ -25,7 +25,7 @@ android {
compileSdkVersion 33 compileSdkVersion 33
defaultConfig { defaultConfig {
minSdkVersion 23 minSdkVersion 21
targetSdkVersion 33 targetSdkVersion 33
} }

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- ownCloud Android Library is available under MIT license <!-- ownCloud Android Library is available under MIT license
Copyright (C) 2023 ownCloud GmbH. Copyright (C) 2016 ownCloud GmbH.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,6 +25,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- USE_CREDENTIALS, MANAGE_ACCOUNTS and AUTHENTICATE_ACCOUNTS are needed for API < 23.
In API >= 23 the do not exist anymore -->
<uses-permission
android:name="android.permission.MANAGE_ACCOUNTS"
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest> </manifest>

View File

@ -36,7 +36,7 @@ import java.net.URL
class CopyMethod( class CopyMethod(
val url: URL, val url: URL,
private val destinationUrl: String, private val destinationUrl: String,
val forceOverride: Boolean = false private val forceOverride: Boolean = false
) : DavMethod(url) { ) : DavMethod(url) {
@Throws(Exception::class) @Throws(Exception::class)
public override fun onDavExecute(davResource: DavOCResource): Int { public override fun onDavExecute(davResource: DavOCResource): Int {

View File

@ -36,7 +36,7 @@ import java.net.URL
class MoveMethod( class MoveMethod(
url: URL, url: URL,
private val destinationUrl: String, private val destinationUrl: String,
val forceOverride: Boolean = false private val forceOverride: Boolean = false
) : DavMethod(url) { ) : DavMethod(url) {
@Throws(Exception::class) @Throws(Exception::class)
override fun onDavExecute(davResource: DavOCResource): Int { override fun onDavExecute(davResource: DavOCResource): Int {

View File

@ -37,14 +37,14 @@ import com.squareup.moshi.Moshi
import timber.log.Timber import timber.log.Timber
import java.net.URL import java.net.URL
class GetRemoteAppRegistryOperation(private val appUrl: String?) : RemoteOperation<AppRegistryResponse>() { class GetRemoteAppRegistryOperation : RemoteOperation<AppRegistryResponse>() {
override fun run(client: OwnCloudClient): RemoteOperationResult<AppRegistryResponse> { override fun run(client: OwnCloudClient): RemoteOperationResult<AppRegistryResponse> {
var result: RemoteOperationResult<AppRegistryResponse> var result: RemoteOperationResult<AppRegistryResponse>
try { try {
val uriBuilder = client.baseUri.buildUpon().apply { val uriBuilder = client.baseUri.buildUpon().apply {
appendEncodedPath(appUrl) appendEncodedPath(APP_REGISTRY_ENDPOINT)
} }
val getMethod = GetMethod(URL(uriBuilder.build().toString())) val getMethod = GetMethod(URL(uriBuilder.build().toString()))
val status = client.executeHttpMethod(getMethod) val status = client.executeHttpMethod(getMethod)
@ -75,4 +75,8 @@ class GetRemoteAppRegistryOperation(private val appUrl: String?) : RemoteOperati
return result return result
} }
companion object {
private const val APP_REGISTRY_ENDPOINT = "app/list"
}
} }

View File

@ -28,7 +28,7 @@ import com.owncloud.android.lib.resources.Service
import com.owncloud.android.lib.resources.appregistry.responses.AppRegistryResponse import com.owncloud.android.lib.resources.appregistry.responses.AppRegistryResponse
interface AppRegistryService : Service { interface AppRegistryService : Service {
fun getAppRegistry(appUrl: String?): RemoteOperationResult<AppRegistryResponse> fun getAppRegistry(): RemoteOperationResult<AppRegistryResponse>
fun getUrlToOpenInWeb( fun getUrlToOpenInWeb(
openWebEndpoint: String, openWebEndpoint: String,

View File

@ -31,8 +31,8 @@ import com.owncloud.android.lib.resources.appregistry.GetUrlToOpenInWebRemoteOpe
import com.owncloud.android.lib.resources.appregistry.responses.AppRegistryResponse import com.owncloud.android.lib.resources.appregistry.responses.AppRegistryResponse
class OCAppRegistryService(override val client: OwnCloudClient) : AppRegistryService { class OCAppRegistryService(override val client: OwnCloudClient) : AppRegistryService {
override fun getAppRegistry(appUrl: String?): RemoteOperationResult<AppRegistryResponse> = override fun getAppRegistry(): RemoteOperationResult<AppRegistryResponse> =
GetRemoteAppRegistryOperation(appUrl).execute(client) GetRemoteAppRegistryOperation().execute(client)
override fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String, appName: String): RemoteOperationResult<String> = override fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String, appName: String): RemoteOperationResult<String> =
GetUrlToOpenInWebRemoteOperation( GetUrlToOpenInWebRemoteOperation(

View File

@ -54,8 +54,9 @@ class CheckPathExistenceRemoteOperation(
) : RemoteOperation<Boolean>() { ) : RemoteOperation<Boolean>() {
override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> { override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> {
val baseStringUrl = spaceWebDavUrl ?: if (isUserLoggedIn) client.userFilesWebDavUri.toString() else client.baseFilesWebDavUri.toString() val baseStringUrl = spaceWebDavUrl ?: if (isUserLoggedIn) client.baseFilesWebDavUri.toString()
val stringUrl = if (isUserLoggedIn) baseStringUrl + WebdavUtils.encodePath(remotePath) else baseStringUrl else client.userFilesWebDavUri.toString()
val stringUrl = baseStringUrl + WebdavUtils.encodePath(remotePath)
return try { return try {
val propFindMethod = PropfindMethod(URL(stringUrl), 0, allPropSet).apply { val propFindMethod = PropfindMethod(URL(stringUrl), 0, allPropSet).apply {
@ -80,7 +81,6 @@ class CheckPathExistenceRemoteOperation(
e, e,
"Existence check for $stringUrl : ${result.logMessage}" "Existence check for $stringUrl : ${result.logMessage}"
) )
result.data = false
result result
} }
} }

View File

@ -45,7 +45,6 @@ import java.util.concurrent.TimeUnit
* @author Christian Schabesberger * @author Christian Schabesberger
* @author David González V. * @author David González V.
* @author Juan Carlos Garrote Gascón * @author Juan Carlos Garrote Gascón
* @author Manuel Plazas Palacio
* *
* @param sourceRemotePath Remote path of the file/folder to copy. * @param sourceRemotePath Remote path of the file/folder to copy.
* @param targetRemotePath Remote path desired for the file/folder to copy it. * @param targetRemotePath Remote path desired for the file/folder to copy it.
@ -55,7 +54,6 @@ class CopyRemoteFileOperation(
private val targetRemotePath: String, private val targetRemotePath: String,
private val sourceSpaceWebDavUrl: String? = null, private val sourceSpaceWebDavUrl: String? = null,
private val targetSpaceWebDavUrl: String? = null, private val targetSpaceWebDavUrl: String? = null,
private val forceOverride: Boolean = false,
) : RemoteOperation<String>() { ) : RemoteOperation<String>() {
/** /**
@ -76,11 +74,9 @@ class CopyRemoteFileOperation(
var result: RemoteOperationResult<String> var result: RemoteOperationResult<String>
try { try {
val copyMethod = CopyMethod( val copyMethod = CopyMethod(
url = URL((sourceSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)), URL((sourceSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)),
destinationUrl = (targetSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath), (targetSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath),
forceOverride = forceOverride,
).apply { ).apply {
addRequestHeaders(this)
setReadTimeout(COPY_READ_TIMEOUT, TimeUnit.SECONDS) setReadTimeout(COPY_READ_TIMEOUT, TimeUnit.SECONDS)
setConnectionTimeout(COPY_CONNECTION_TIMEOUT, TimeUnit.SECONDS) setConnectionTimeout(COPY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
} }
@ -91,7 +87,6 @@ class CopyRemoteFileOperation(
result = RemoteOperationResult(ResultCode.OK) result = RemoteOperationResult(ResultCode.OK)
result.setData(fileRemoteId) result.setData(fileRemoteId)
} }
isPreconditionFailed(status) -> { isPreconditionFailed(status) -> {
result = RemoteOperationResult(ResultCode.INVALID_OVERWRITE) result = RemoteOperationResult(ResultCode.INVALID_OVERWRITE)
client.exhaustResponse(copyMethod.getResponseBodyAsStream()) client.exhaustResponse(copyMethod.getResponseBodyAsStream())
@ -99,7 +94,6 @@ class CopyRemoteFileOperation(
/// for other errors that could be explicitly handled, check first: /// for other errors that could be explicitly handled, check first:
/// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4 /// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4
} }
else -> { else -> {
result = RemoteOperationResult(copyMethod) result = RemoteOperationResult(copyMethod)
client.exhaustResponse(copyMethod.getResponseBodyAsStream()) client.exhaustResponse(copyMethod.getResponseBodyAsStream())
@ -113,13 +107,6 @@ class CopyRemoteFileOperation(
return result return result
} }
private fun addRequestHeaders(copyMethod: CopyMethod) {
//Adding this because the library has an error with override
if (copyMethod.forceOverride) {
copyMethod.setRequestHeader(OVERWRITE, TRUE)
}
}
private fun isSuccess(status: Int) = status.isOneOf(HttpConstants.HTTP_CREATED, HttpConstants.HTTP_NO_CONTENT) private fun isSuccess(status: Int) = status.isOneOf(HttpConstants.HTTP_CREATED, HttpConstants.HTTP_NO_CONTENT)
private fun isPreconditionFailed(status: Int) = status == HttpConstants.HTTP_PRECONDITION_FAILED private fun isPreconditionFailed(status: Int) = status == HttpConstants.HTTP_PRECONDITION_FAILED
@ -127,7 +114,5 @@ class CopyRemoteFileOperation(
companion object { companion object {
private const val COPY_READ_TIMEOUT = 10L private const val COPY_READ_TIMEOUT = 10L
private const val COPY_CONNECTION_TIMEOUT = 6L private const val COPY_CONNECTION_TIMEOUT = 6L
private const val OVERWRITE = "overwrite"
private const val TRUE = "T"
} }
} }

View File

@ -46,7 +46,6 @@ import java.util.concurrent.TimeUnit
* @author David González Verdugo * @author David González Verdugo
* @author Abel García de Prada * @author Abel García de Prada
* @author Juan Carlos Garrote Gascón * @author Juan Carlos Garrote Gascón
* @author Manuel Plazas Palacio
* *
* @param sourceRemotePath Remote path of the file/folder to copy. * @param sourceRemotePath Remote path of the file/folder to copy.
* @param targetRemotePath Remote path desired for the file/folder to copy it. * @param targetRemotePath Remote path desired for the file/folder to copy it.
@ -55,7 +54,6 @@ open class MoveRemoteFileOperation(
private val sourceRemotePath: String, private val sourceRemotePath: String,
private val targetRemotePath: String, private val targetRemotePath: String,
private val spaceWebDavUrl: String? = null, private val spaceWebDavUrl: String? = null,
private val forceOverride: Boolean = false,
) : RemoteOperation<Unit>() { ) : RemoteOperation<Unit>() {
/** /**
@ -82,7 +80,6 @@ open class MoveRemoteFileOperation(
val moveMethod = MoveMethod( val moveMethod = MoveMethod(
url = URL((spaceWebDavUrl ?: srcWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)), url = URL((spaceWebDavUrl ?: srcWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)),
destinationUrl = (spaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath), destinationUrl = (spaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath),
forceOverride = forceOverride,
).apply { ).apply {
addRequestHeaders(this) addRequestHeaders(this)
setReadTimeout(MOVE_READ_TIMEOUT, TimeUnit.SECONDS) setReadTimeout(MOVE_READ_TIMEOUT, TimeUnit.SECONDS)
@ -95,7 +92,6 @@ open class MoveRemoteFileOperation(
isSuccess(status) -> { isSuccess(status) -> {
result = RemoteOperationResult<Unit>(ResultCode.OK) result = RemoteOperationResult<Unit>(ResultCode.OK)
} }
isPreconditionFailed(status) -> { isPreconditionFailed(status) -> {
result = RemoteOperationResult<Unit>(ResultCode.INVALID_OVERWRITE) result = RemoteOperationResult<Unit>(ResultCode.INVALID_OVERWRITE)
client.exhaustResponse(moveMethod.getResponseBodyAsStream()) client.exhaustResponse(moveMethod.getResponseBodyAsStream())
@ -103,7 +99,6 @@ open class MoveRemoteFileOperation(
/// for other errors that could be explicitly handled, check first: /// for other errors that could be explicitly handled, check first:
/// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4 /// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4
} }
else -> { else -> {
result = RemoteOperationResult<Unit>(moveMethod) result = RemoteOperationResult<Unit>(moveMethod)
client.exhaustResponse(moveMethod.getResponseBodyAsStream()) client.exhaustResponse(moveMethod.getResponseBodyAsStream())
@ -130,10 +125,6 @@ open class MoveRemoteFileOperation(
* In case new headers are needed, override this method * In case new headers are needed, override this method
*/ */
open fun addRequestHeaders(moveMethod: MoveMethod) { open fun addRequestHeaders(moveMethod: MoveMethod) {
//Adding this because the library has an error with override
if (moveMethod.forceOverride) {
moveMethod.setRequestHeader(OVERWRITE, TRUE)
}
} }
private fun isSuccess(status: Int) = status.isOneOf(HttpConstants.HTTP_CREATED, HttpConstants.HTTP_NO_CONTENT) private fun isSuccess(status: Int) = status.isOneOf(HttpConstants.HTTP_CREATED, HttpConstants.HTTP_NO_CONTENT)
@ -143,7 +134,5 @@ open class MoveRemoteFileOperation(
companion object { companion object {
private const val MOVE_READ_TIMEOUT = 10L private const val MOVE_READ_TIMEOUT = 10L
private const val MOVE_CONNECTION_TIMEOUT = 6L private const val MOVE_CONNECTION_TIMEOUT = 6L
private const val OVERWRITE = "overwrite"
private const val TRUE = "T"
} }
} }

View File

@ -106,7 +106,7 @@ class RenameRemoteFileOperation(
* @return 'True' if the target path is already used by an existing file. * @return 'True' if the target path is already used by an existing file.
*/ */
private fun targetPathIsUsed(client: OwnCloudClient): Boolean { private fun targetPathIsUsed(client: OwnCloudClient): Boolean {
val checkPathExistenceRemoteOperation = CheckPathExistenceRemoteOperation(newRemotePath, true) val checkPathExistenceRemoteOperation = CheckPathExistenceRemoteOperation(newRemotePath, false)
val exists = checkPathExistenceRemoteOperation.execute(client) val exists = checkPathExistenceRemoteOperation.execute(client)
return exists.isSuccess return exists.isSuccess
} }

View File

@ -39,8 +39,7 @@ interface FileService : Service {
targetRemotePath: String, targetRemotePath: String,
sourceSpaceWebDavUrl: String?, sourceSpaceWebDavUrl: String?,
targetSpaceWebDavUrl: String?, targetSpaceWebDavUrl: String?,
replace: Boolean, ): RemoteOperationResult<String>
): RemoteOperationResult<String?>
fun createFolder( fun createFolder(
remotePath: String, remotePath: String,
@ -58,7 +57,6 @@ interface FileService : Service {
sourceRemotePath: String, sourceRemotePath: String,
targetRemotePath: String, targetRemotePath: String,
spaceWebDavUrl: String?, spaceWebDavUrl: String?,
replace: Boolean,
): RemoteOperationResult<Unit> ): RemoteOperationResult<Unit>
fun readFile( fun readFile(

View File

@ -54,14 +54,12 @@ class OCFileService(override val client: OwnCloudClient) : FileService {
targetRemotePath: String, targetRemotePath: String,
sourceSpaceWebDavUrl: String?, sourceSpaceWebDavUrl: String?,
targetSpaceWebDavUrl: String?, targetSpaceWebDavUrl: String?,
replace: Boolean, ): RemoteOperationResult<String> =
): RemoteOperationResult<String?> =
CopyRemoteFileOperation( CopyRemoteFileOperation(
sourceRemotePath = sourceRemotePath, sourceRemotePath = sourceRemotePath,
targetRemotePath = targetRemotePath, targetRemotePath = targetRemotePath,
sourceSpaceWebDavUrl = sourceSpaceWebDavUrl, sourceSpaceWebDavUrl = sourceSpaceWebDavUrl,
targetSpaceWebDavUrl = targetSpaceWebDavUrl, targetSpaceWebDavUrl = targetSpaceWebDavUrl,
forceOverride = replace,
).execute(client) ).execute(client)
override fun createFolder( override fun createFolder(
@ -90,13 +88,11 @@ class OCFileService(override val client: OwnCloudClient) : FileService {
sourceRemotePath: String, sourceRemotePath: String,
targetRemotePath: String, targetRemotePath: String,
spaceWebDavUrl: String?, spaceWebDavUrl: String?,
replace: Boolean,
): RemoteOperationResult<Unit> = ): RemoteOperationResult<Unit> =
MoveRemoteFileOperation( MoveRemoteFileOperation(
sourceRemotePath = sourceRemotePath, sourceRemotePath = sourceRemotePath,
targetRemotePath = targetRemotePath, targetRemotePath = targetRemotePath,
spaceWebDavUrl = spaceWebDavUrl, spaceWebDavUrl = spaceWebDavUrl,
forceOverride = replace,
).execute(client) ).execute(client)
override fun readFile( override fun readFile(

View File

@ -89,6 +89,8 @@ class CreateRemoteShareOperation(
var expirationDateInMillis: Long = INIT_EXPIRATION_DATE_IN_MILLIS // Expiration date to set for the public link var expirationDateInMillis: Long = INIT_EXPIRATION_DATE_IN_MILLIS // Expiration date to set for the public link
var publicUpload: Boolean = false // Upload permissions for the public link (only folders)
var retrieveShareDetails = false // To retrieve more info about the just created share var retrieveShareDetails = false // To retrieve more info about the just created share
private fun buildRequestUri(baseUri: Uri) = private fun buildRequestUri(baseUri: Uri) =
@ -97,7 +99,7 @@ class CreateRemoteShareOperation(
.appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT) .appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT)
.build() .build()
private fun parseResponse(response: String): ShareResponse { private fun parseResponse(response: String): ShareResponse? {
val moshi = Moshi.Builder().build() val moshi = Moshi.Builder().build()
val commonOcsType: Type = Types.newParameterizedType(CommonOcsResponse::class.java, ShareItem::class.java) val commonOcsType: Type = Types.newParameterizedType(CommonOcsResponse::class.java, ShareItem::class.java)
val adapter: JsonAdapter<CommonOcsResponse<ShareItem>> = moshi.adapter(commonOcsType) val adapter: JsonAdapter<CommonOcsResponse<ShareItem>> = moshi.adapter(commonOcsType)
@ -153,10 +155,12 @@ class CreateRemoteShareOperation(
formBodyBuilder.add(PARAM_EXPIRATION_DATE, formattedExpirationDate) formBodyBuilder.add(PARAM_EXPIRATION_DATE, formattedExpirationDate)
} }
if (publicUpload) {
formBodyBuilder.add(PARAM_PUBLIC_UPLOAD, publicUpload.toString())
}
if (password.isNotEmpty()) { if (password.isNotEmpty()) {
formBodyBuilder.add(PARAM_PASSWORD, password) formBodyBuilder.add(PARAM_PASSWORD, password)
} }
if (RemoteShare.DEFAULT_PERMISSION != permissions) { if (RemoteShare.DEFAULT_PERMISSION != permissions) {
formBodyBuilder.add(PARAM_PERMISSIONS, permissions.toString()) formBodyBuilder.add(PARAM_PERMISSIONS, permissions.toString())
} }
@ -203,6 +207,7 @@ class CreateRemoteShareOperation(
private const val PARAM_SHARE_TYPE = "shareType" private const val PARAM_SHARE_TYPE = "shareType"
private const val PARAM_SHARE_WITH = "shareWith" private const val PARAM_SHARE_WITH = "shareWith"
private const val PARAM_PASSWORD = "password" private const val PARAM_PASSWORD = "password"
private const val PARAM_PUBLIC_UPLOAD = "publicUpload"
private const val PARAM_PERMISSIONS = "permissions" private const val PARAM_PERMISSIONS = "permissions"
//Arguments - constant values //Arguments - constant values

View File

@ -103,6 +103,13 @@ class UpdateRemoteShareOperation
*/ */
var permissions: Int = DEFAULT_PERMISSION var permissions: Int = DEFAULT_PERMISSION
/**
* Enable upload permissions to update in Share resource.
*
* Null results in no update applied to the upload permission.
*/
var publicUpload: Boolean? = null
var retrieveShareDetails = false // To retrieve more info about the just updated share var retrieveShareDetails = false // To retrieve more info about the just updated share
private fun buildRequestUri(baseUri: Uri) = private fun buildRequestUri(baseUri: Uri) =
@ -112,7 +119,7 @@ class UpdateRemoteShareOperation
.appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT) .appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT)
.build() .build()
private fun parseResponse(response: String): ShareResponse { private fun parseResponse(response: String): ShareResponse? {
val moshi = Moshi.Builder().build() val moshi = Moshi.Builder().build()
val commonOcsType: Type = Types.newParameterizedType(CommonOcsResponse::class.java, ShareItem::class.java) val commonOcsType: Type = Types.newParameterizedType(CommonOcsResponse::class.java, ShareItem::class.java)
val adapter: JsonAdapter<CommonOcsResponse<ShareItem>> = moshi.adapter(commonOcsType) val adapter: JsonAdapter<CommonOcsResponse<ShareItem>> = moshi.adapter(commonOcsType)
@ -174,6 +181,10 @@ class UpdateRemoteShareOperation
formBodyBuilder.add(PARAM_EXPIRATION_DATE, formattedExpirationDate) formBodyBuilder.add(PARAM_EXPIRATION_DATE, formattedExpirationDate)
} // else, ignore - no update } // else, ignore - no update
if (publicUpload != null) {
formBodyBuilder.add(PARAM_PUBLIC_UPLOAD, publicUpload.toString())
}
// IMPORTANT: permissions parameter needs to be updated after mPublicUpload parameter, // IMPORTANT: permissions parameter needs to be updated after mPublicUpload parameter,
// otherwise they would be set always as 1 (READ) in the server when mPublicUpload was updated // otherwise they would be set always as 1 (READ) in the server when mPublicUpload was updated
if (permissions > DEFAULT_PERMISSION) { if (permissions > DEFAULT_PERMISSION) {
@ -222,6 +233,7 @@ class UpdateRemoteShareOperation
private const val PARAM_PASSWORD = "password" private const val PARAM_PASSWORD = "password"
private const val PARAM_EXPIRATION_DATE = "expireDate" private const val PARAM_EXPIRATION_DATE = "expireDate"
private const val PARAM_PERMISSIONS = "permissions" private const val PARAM_PERMISSIONS = "permissions"
private const val PARAM_PUBLIC_UPLOAD = "publicUpload"
//Arguments - constant values //Arguments - constant values
private const val FORMAT_EXPIRATION_DATE = "yyyy-MM-dd" private const val FORMAT_EXPIRATION_DATE = "yyyy-MM-dd"

View File

@ -46,6 +46,7 @@ interface ShareService : Service {
name: String, name: String,
password: String, password: String,
expirationDate: Long, expirationDate: Long,
publicUpload: Boolean
): RemoteOperationResult<ShareResponse> ): RemoteOperationResult<ShareResponse>
fun updateShare( fun updateShare(
@ -54,6 +55,7 @@ interface ShareService : Service {
password: String?, password: String?,
expirationDate: Long, expirationDate: Long,
permissions: Int, permissions: Int,
publicUpload: Boolean
): RemoteOperationResult<ShareResponse> ): RemoteOperationResult<ShareResponse>
fun deleteShare(remoteId: String): RemoteOperationResult<Unit> fun deleteShare(remoteId: String): RemoteOperationResult<Unit>

View File

@ -55,6 +55,7 @@ class OCShareService(override val client: OwnCloudClient) : ShareService {
name: String, name: String,
password: String, password: String,
expirationDate: Long, expirationDate: Long,
publicUpload: Boolean
): RemoteOperationResult<ShareResponse> = ): RemoteOperationResult<ShareResponse> =
CreateRemoteShareOperation( CreateRemoteShareOperation(
remoteFilePath, remoteFilePath,
@ -65,6 +66,7 @@ class OCShareService(override val client: OwnCloudClient) : ShareService {
this.name = name this.name = name
this.password = password this.password = password
this.expirationDateInMillis = expirationDate this.expirationDateInMillis = expirationDate
this.publicUpload = publicUpload
this.retrieveShareDetails = true this.retrieveShareDetails = true
}.execute(client) }.execute(client)
@ -74,6 +76,7 @@ class OCShareService(override val client: OwnCloudClient) : ShareService {
password: String?, password: String?,
expirationDate: Long, expirationDate: Long,
permissions: Int, permissions: Int,
publicUpload: Boolean
): RemoteOperationResult<ShareResponse> = ): RemoteOperationResult<ShareResponse> =
UpdateRemoteShareOperation( UpdateRemoteShareOperation(
remoteId remoteId
@ -82,6 +85,7 @@ class OCShareService(override val client: OwnCloudClient) : ShareService {
this.password = password this.password = password
this.expirationDateInMillis = expirationDate this.expirationDateInMillis = expirationDate
this.permissions = permissions this.permissions = permissions
this.publicUpload = publicUpload
this.retrieveShareDetails = true this.retrieveShareDetails = true
}.execute(client) }.execute(client)

View File

@ -40,7 +40,7 @@ class OCServerInfoService : ServerInfoService {
): RemoteOperationResult<Boolean> = ): RemoteOperationResult<Boolean> =
CheckPathExistenceRemoteOperation( CheckPathExistenceRemoteOperation(
remotePath = path, remotePath = path,
isUserLoggedIn = isUserLoggedIn, isUserLoggedIn = true,
).execute(client) ).execute(client)
override fun getRemoteStatus( override fun getRemoteStatus(