mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 16:36:13 +00:00
Include services implementation so that can be used by library users
This commit is contained in:
parent
cf06126ce1
commit
bec5643714
@ -21,7 +21,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.owncloud.android.lib.resources.files
|
package com.owncloud.android.lib.resources.files.services
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.Service
|
import com.owncloud.android.lib.resources.Service
|
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* ownCloud Android client application
|
||||||
|
*
|
||||||
|
* @author Abel García de Prada
|
||||||
|
* Copyright (C) 2020 ownCloud GmbH.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.resources.files.services.implementation
|
||||||
|
|
||||||
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
|
import com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation
|
||||||
|
import com.owncloud.android.lib.resources.files.services.FileService
|
||||||
|
|
||||||
|
class OCFileService(override val client: OwnCloudClient) :
|
||||||
|
FileService {
|
||||||
|
override fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean> =
|
||||||
|
CheckPathExistenceRemoteOperation(
|
||||||
|
remotePath = path,
|
||||||
|
isUserLogged = isUserLogged
|
||||||
|
).execute(client)
|
||||||
|
}
|
@ -18,10 +18,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.owncloud.android.lib.resources.shares
|
package com.owncloud.android.lib.resources.shares.services
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.Service
|
import com.owncloud.android.lib.resources.Service
|
||||||
|
import com.owncloud.android.lib.resources.shares.ShareParserResult
|
||||||
|
import com.owncloud.android.lib.resources.shares.ShareType
|
||||||
|
|
||||||
interface ShareService : Service {
|
interface ShareService : Service {
|
||||||
fun getShares(
|
fun getShares(
|
@ -18,7 +18,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.owncloud.android.lib.resources.shares
|
package com.owncloud.android.lib.resources.shares.services
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.Service
|
import com.owncloud.android.lib.resources.Service
|
@ -0,0 +1,91 @@
|
|||||||
|
/**
|
||||||
|
* ownCloud Android client application
|
||||||
|
*
|
||||||
|
* @author David González Verdugo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 ownCloud GmbH.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.resources.shares.services.implementation
|
||||||
|
|
||||||
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
|
import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation
|
||||||
|
import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation
|
||||||
|
import com.owncloud.android.lib.resources.shares.RemoveRemoteShareOperation
|
||||||
|
import com.owncloud.android.lib.resources.shares.ShareParserResult
|
||||||
|
import com.owncloud.android.lib.resources.shares.ShareType
|
||||||
|
import com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation
|
||||||
|
import com.owncloud.android.lib.resources.shares.services.ShareService
|
||||||
|
|
||||||
|
class OCShareService(override val client: OwnCloudClient) :
|
||||||
|
ShareService {
|
||||||
|
override fun getShares(
|
||||||
|
remoteFilePath: String,
|
||||||
|
reshares: Boolean,
|
||||||
|
subfiles: Boolean
|
||||||
|
): RemoteOperationResult<ShareParserResult> = GetRemoteSharesForFileOperation(
|
||||||
|
remoteFilePath,
|
||||||
|
reshares,
|
||||||
|
subfiles
|
||||||
|
).execute(client)
|
||||||
|
|
||||||
|
override fun insertShare(
|
||||||
|
remoteFilePath: String,
|
||||||
|
shareType: ShareType,
|
||||||
|
shareWith: String,
|
||||||
|
permissions: Int,
|
||||||
|
name: String,
|
||||||
|
password: String,
|
||||||
|
expirationDate: Long,
|
||||||
|
publicUpload: Boolean
|
||||||
|
): RemoteOperationResult<ShareParserResult> =
|
||||||
|
CreateRemoteShareOperation(
|
||||||
|
remoteFilePath,
|
||||||
|
shareType,
|
||||||
|
shareWith,
|
||||||
|
permissions
|
||||||
|
).apply {
|
||||||
|
this.name = name
|
||||||
|
this.password = password
|
||||||
|
this.expirationDateInMillis = expirationDate
|
||||||
|
this.publicUpload = publicUpload
|
||||||
|
this.retrieveShareDetails = true
|
||||||
|
}.execute(client)
|
||||||
|
|
||||||
|
override fun updateShare(
|
||||||
|
remoteId: Long,
|
||||||
|
name: String,
|
||||||
|
password: String?,
|
||||||
|
expirationDate: Long,
|
||||||
|
permissions: Int,
|
||||||
|
publicUpload: Boolean
|
||||||
|
): RemoteOperationResult<ShareParserResult> =
|
||||||
|
UpdateRemoteShareOperation(
|
||||||
|
remoteId
|
||||||
|
).apply {
|
||||||
|
this.name = name
|
||||||
|
this.password = password
|
||||||
|
this.expirationDateInMillis = expirationDate
|
||||||
|
this.permissions = permissions
|
||||||
|
this.publicUpload = publicUpload
|
||||||
|
this.retrieveShareDetails = true
|
||||||
|
}.execute(client)
|
||||||
|
|
||||||
|
override fun deleteShare(remoteId: Long): RemoteOperationResult<ShareParserResult> =
|
||||||
|
RemoveRemoteShareOperation(
|
||||||
|
remoteId
|
||||||
|
).execute(client)
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* ownCloud Android client application
|
||||||
|
*
|
||||||
|
* @author David González Verdugo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 ownCloud GmbH.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.resources.shares.services.implementation
|
||||||
|
|
||||||
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
|
import com.owncloud.android.lib.resources.shares.GetRemoteShareesOperation
|
||||||
|
import com.owncloud.android.lib.resources.shares.services.ShareeService
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
class OCShareeService(override val client: OwnCloudClient) :
|
||||||
|
ShareeService {
|
||||||
|
override fun getSharees(
|
||||||
|
searchString: String,
|
||||||
|
page: Int,
|
||||||
|
perPage: Int
|
||||||
|
): RemoteOperationResult<ArrayList<JSONObject>> =
|
||||||
|
GetRemoteShareesOperation(
|
||||||
|
searchString,
|
||||||
|
page,
|
||||||
|
perPage
|
||||||
|
).execute(client)
|
||||||
|
}
|
@ -18,10 +18,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.owncloud.android.lib.resources.status
|
package com.owncloud.android.lib.resources.status.services
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.Service
|
import com.owncloud.android.lib.resources.Service
|
||||||
|
import com.owncloud.android.lib.resources.status.RemoteCapability
|
||||||
|
|
||||||
interface CapabilityService: Service {
|
interface CapabilityService: Service {
|
||||||
fun getCapabilities() : RemoteOperationResult<RemoteCapability>
|
fun getCapabilities() : RemoteOperationResult<RemoteCapability>
|
@ -21,7 +21,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.owncloud.android.lib.resources.status
|
package com.owncloud.android.lib.resources.status.services
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* ownCloud Android client application
|
||||||
|
*
|
||||||
|
* @author David González Verdugo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 ownCloud GmbH.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.resources.status.services.implementation
|
||||||
|
|
||||||
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
|
import com.owncloud.android.lib.resources.status.services.CapabilityService
|
||||||
|
import com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation
|
||||||
|
import com.owncloud.android.lib.resources.status.RemoteCapability
|
||||||
|
|
||||||
|
class OCCapabilityService(override val client: OwnCloudClient) :
|
||||||
|
CapabilityService {
|
||||||
|
override fun getCapabilities(): RemoteOperationResult<RemoteCapability> =
|
||||||
|
GetRemoteCapabilitiesOperation().execute(client)
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* ownCloud Android client application
|
||||||
|
*
|
||||||
|
* @author Abel García de Prada
|
||||||
|
* Copyright (C) 2020 ownCloud GmbH.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.resources.status.services.implementation
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
|
import com.owncloud.android.lib.resources.status.services.ServerInfoService
|
||||||
|
import com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation
|
||||||
|
import com.owncloud.android.lib.resources.status.GetRemoteStatusOperation
|
||||||
|
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||||
|
|
||||||
|
class OCServerInfoService : ServerInfoService {
|
||||||
|
override fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean> =
|
||||||
|
CheckPathExistenceRemoteOperation(
|
||||||
|
remotePath = path,
|
||||||
|
isUserLogged = true
|
||||||
|
).execute(createClientFromPath(path))
|
||||||
|
|
||||||
|
override fun getRemoteStatus(path: String): RemoteOperationResult<OwnCloudVersion> =
|
||||||
|
GetRemoteStatusOperation().execute(createClientFromPath(path))
|
||||||
|
|
||||||
|
private fun createClientFromPath(path: String): OwnCloudClient {
|
||||||
|
return OwnCloudClient(Uri.parse(path))
|
||||||
|
}
|
||||||
|
}
|
@ -22,10 +22,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.owncloud.android.lib.resources.users
|
package com.owncloud.android.lib.resources.users.services
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.Service
|
import com.owncloud.android.lib.resources.Service
|
||||||
|
import com.owncloud.android.lib.resources.users.RemoteUserInfo
|
||||||
|
|
||||||
interface UserService: Service {
|
interface UserService: Service {
|
||||||
fun getUserInfo() : RemoteOperationResult<RemoteUserInfo>
|
fun getUserInfo() : RemoteOperationResult<RemoteUserInfo>
|
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* ownCloud Android client application
|
||||||
|
*
|
||||||
|
* @author Abel García de Prada
|
||||||
|
* Copyright (C) 2020 ownCloud GmbH.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.resources.users.services.implementation
|
||||||
|
|
||||||
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
|
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation
|
||||||
|
import com.owncloud.android.lib.resources.users.RemoteUserInfo
|
||||||
|
import com.owncloud.android.lib.resources.users.services.UserService
|
||||||
|
|
||||||
|
class OCUserService(override val client: OwnCloudClient) :
|
||||||
|
UserService {
|
||||||
|
override fun getUserInfo(): RemoteOperationResult<RemoteUserInfo> =
|
||||||
|
GetRemoteUserInfoOperation().execute(client)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user