From c05a11a7b4ec173797c3217efc8ec5526d612ae7 Mon Sep 17 00:00:00 2001 From: davigonz Date: Mon, 7 Oct 2019 15:22:20 +0200 Subject: [PATCH] Create some service interfaces as facade for remote operations --- .../owncloud/android/lib/resources/Service.kt | 31 +++++++++++ .../lib/resources/shares/ShareService.kt | 54 +++++++++++++++++++ .../lib/resources/shares/ShareeService.kt | 34 ++++++++++++ .../lib/resources/status/CapabilityService.kt | 28 ++++++++++ 4 files changed, 147 insertions(+) create mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt create mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt create mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt create mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt new file mode 100644 index 00000000..0fa90756 --- /dev/null +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt @@ -0,0 +1,31 @@ +/** + * ownCloud Android client application + * + * @author David González Verdugo + * + * Copyright (C) 2019 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 . + */ + +package com.owncloud.android.lib.resources + +import com.owncloud.android.lib.common.OwnCloudClient + +/** + * Facade to perform network calls without the verbosity of remote operations + */ + +interface Service { + val client: OwnCloudClient +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt new file mode 100644 index 00000000..e8b728b3 --- /dev/null +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt @@ -0,0 +1,54 @@ +/** + * ownCloud Android client application + * + * @author David González Verdugo + * + * Copyright (C) 2019 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 . + */ + +package com.owncloud.android.lib.resources.shares + +import com.owncloud.android.lib.common.operations.RemoteOperationResult +import com.owncloud.android.lib.resources.Service + +interface ShareService : Service { + fun getShares( + remoteFilePath: String, + reshares: Boolean, + subfiles: Boolean + ): RemoteOperationResult + + fun insertShare( + remoteFilePath: String, + shareType: ShareType, + shareWith: String, + permissions: Int, + name: String, + password: String, + expirationDate: Long, + publicUpload: Boolean + ): RemoteOperationResult + + fun updateShare( + remoteId: Long, + name: String, + password: String?, + expirationDate: Long, + permissions: Int, + publicUpload: Boolean + ): RemoteOperationResult + + fun deleteShare(remoteId: Long): RemoteOperationResult +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt new file mode 100644 index 00000000..ba6426dc --- /dev/null +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt @@ -0,0 +1,34 @@ +/** + * ownCloud Android client application + * + * @author David González Verdugo + * + * Copyright (C) 2019 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 . + */ + +package com.owncloud.android.lib.resources.shares + +import com.owncloud.android.lib.common.operations.RemoteOperationResult +import com.owncloud.android.lib.resources.Service +import org.json.JSONObject +import java.util.ArrayList + +interface ShareeService : Service { + fun getSharees( + searchString: String, + page: Int, + perPage: Int + ): RemoteOperationResult> +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt new file mode 100644 index 00000000..1253f9ca --- /dev/null +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt @@ -0,0 +1,28 @@ +/** + * ownCloud Android client application + * + * @author David González Verdugo + * + * Copyright (C) 2019 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 . + */ + +package com.owncloud.android.lib.resources.status + +import com.owncloud.android.lib.common.operations.RemoteOperationResult +import com.owncloud.android.lib.resources.Service + +interface CapabilityService: Service { + fun getCapabilities() : RemoteOperationResult +}