Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 4f00155

Browse files
committed
Save spaces-related capabilities in database
1 parent e30246c commit 4f00155

File tree

3 files changed

+79
-50
lines changed

3 files changed

+79
-50
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import java.net.URL
4545

4646
/**
4747
* Get the Capabilities from the server
48-
* Save in Result.getData in a RemoteCapability object
48+
* Save Result.getData in a RemoteCapability object
4949
*
5050
* @author masensio
5151
* @author David González Verdugo

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/RemoteCapability.kt

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
/* ownCloud Android Library is available under MIT license
2-
* @author masensio
3-
* @author David González Verdugo
4-
* @author Abel García de Prada
5-
* Copyright (C) 2020 ownCloud GmbH.
1+
/**
2+
* ownCloud Android Library is available under MIT license
3+
*
4+
* @author masensio
5+
* @author David González Verdugo
6+
* @author Abel García de Prada
7+
* @author Juan Carlos Garrote Gascón
68
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
8-
* of this software and associated documentation files (the "Software"), to deal
9-
* in the Software without restriction, including without limitation the rights
10-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the Software is
12-
* furnished to do so, subject to the following conditions:
9+
* Copyright (C) 2022 ownCloud GmbH.
1310
*
14-
* The above copyright notice and this permission notice shall be included in
15-
* all copies or substantial portions of the Software.
11+
* Permission is hereby granted, free of charge, to any person obtaining a copy
12+
* of this software and associated documentation files (the "Software"), to deal
13+
* in the Software without restriction, including without limitation the rights
14+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
* copies of the Software, and to permit persons to whom the Software is
16+
* furnished to do so, subject to the following conditions:
1617
*
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21-
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22-
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24-
* THE SOFTWARE.
18+
* The above copyright notice and this permission notice shall be included in
19+
* all copies or substantial portions of the Software.
2520
*
21+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28+
* THE SOFTWARE.
2629
*/
30+
2731
package com.owncloud.android.lib.resources.status
2832

2933
/**
@@ -33,7 +37,7 @@ data class RemoteCapability(
3337
var accountName: String = "",
3438

3539
// Server version
36-
var versionMayor: Int = 0,
40+
var versionMajor: Int = 0,
3741
var versionMinor: Int = 0,
3842
var versionMicro: Int = 0,
3943
var versionString: String = "",
@@ -68,7 +72,10 @@ data class RemoteCapability(
6872
var filesUndelete: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN,
6973
var filesVersioning: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN,
7074
val filesPrivateLinks: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN,
71-
val filesAppProviders: List<RemoteOCISProvider>?,
75+
val filesAppProviders: List<RemoteAppProviders>?,
76+
77+
// Spaces
78+
val spaces: RemoteSpaces?,
7279
) {
7380
/**
7481
* Enum for Boolean Type in capabilities, with values:
@@ -101,12 +108,18 @@ data class RemoteCapability(
101108
}
102109
}
103110

104-
data class RemoteOCISProvider(
111+
data class RemoteAppProviders(
105112
val enabled: Boolean,
106113
val version: String,
107114
val appsUrl: String?,
108115
val openUrl: String?,
109116
val openWebUrl: String?,
110117
val newUrl: String?,
111118
)
119+
120+
data class RemoteSpaces(
121+
val enabled: Boolean,
122+
val projects: Boolean,
123+
val shareJail: Boolean,
124+
)
112125
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/responses/CapabilityResponse.kt

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
/* ownCloud Android Library is available under MIT license
2-
* @author Abel García de Prada
3-
* Copyright (C) 2020 ownCloud GmbH.
1+
/**
2+
* ownCloud Android Library is available under MIT license
43
*
5-
* Permission is hereby granted, free of charge, to any person obtaining a copy
6-
* of this software and associated documentation files (the "Software"), to deal
7-
* in the Software without restriction, including without limitation the rights
8-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
* copies of the Software, and to permit persons to whom the Software is
10-
* furnished to do so, subject to the following conditions:
4+
* @author Abel García de Prada
5+
* @author Juan Carlos Garrote Gascón
116
*
12-
* The above copyright notice and this permission notice shall be included in
13-
* all copies or substantial portions of the Software.
7+
* Copyright (C) 2022 ownCloud GmbH.
148
*
15-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19-
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20-
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22-
* THE SOFTWARE.
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
2315
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26+
* THE SOFTWARE.
2427
*/
28+
2529
package com.owncloud.android.lib.resources.status.responses
2630

2731
import com.owncloud.android.lib.resources.status.RemoteCapability
28-
import com.owncloud.android.lib.resources.status.RemoteCapability.CapabilityBooleanType
29-
import com.owncloud.android.lib.resources.status.RemoteCapability.RemoteOCISProvider
32+
import com.owncloud.android.lib.resources.status.RemoteCapability.*
3033
import com.squareup.moshi.Json
3134
import com.squareup.moshi.JsonClass
3235

@@ -37,7 +40,7 @@ data class CapabilityResponse(
3740
val capabilities: Capabilities?
3841
) {
3942
fun toRemoteCapability(): RemoteCapability = RemoteCapability(
40-
versionMayor = serverVersion?.major ?: 0,
43+
versionMajor = serverVersion?.major ?: 0,
4144
versionMinor = serverVersion?.minor ?: 0,
4245
versionMicro = serverVersion?.micro ?: 0,
4346
versionString = serverVersion?.string ?: "",
@@ -70,10 +73,11 @@ data class CapabilityResponse(
7073
filesUndelete = CapabilityBooleanType.fromBooleanValue(capabilities?.fileCapabilities?.undelete),
7174
filesVersioning = CapabilityBooleanType.fromBooleanValue(capabilities?.fileCapabilities?.versioning),
7275
filesPrivateLinks = capabilities?.fileCapabilities?.privateLinks?.let { CapabilityBooleanType.fromBooleanValue(it) } ?: CapabilityBooleanType.UNKNOWN,
73-
filesAppProviders = capabilities?.fileCapabilities?.appProviders?.map { it.toOCISProvider() },
76+
filesAppProviders = capabilities?.fileCapabilities?.appProviders?.map { it.toAppProviders() },
7477
filesSharingFederationIncoming = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingFederation?.incoming),
7578
filesSharingFederationOutgoing = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingFederation?.outgoing),
7679
filesSharingUserProfilePicture = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingUser?.profilePicture),
80+
spaces = capabilities?.spacesCapabilities?.toSpaces(),
7781
)
7882
}
7983

@@ -86,7 +90,9 @@ data class Capabilities(
8690
@Json(name = "files")
8791
val fileCapabilities: FileCapabilities?,
8892
@Json(name = "dav")
89-
val davCapabilities: DavCapabilities?
93+
val davCapabilities: DavCapabilities?,
94+
@Json(name = "spaces")
95+
val spacesCapabilities: SpacesCapabilities?
9096
)
9197

9298
@JsonClass(generateAdapter = true)
@@ -182,14 +188,24 @@ data class AppProvider(
182188
@Json(name = "new_url")
183189
val newUrl: String?,
184190
) {
185-
fun toOCISProvider() = RemoteOCISProvider(enabled, version, appsUrl, openUrl, openWebUrl, newUrl)
191+
fun toAppProviders() = RemoteAppProviders(enabled, version, appsUrl, openUrl, openWebUrl, newUrl)
186192
}
187193

188194
@JsonClass(generateAdapter = true)
189195
data class DavCapabilities(
190196
val chunking: String?
191197
)
192198

199+
@JsonClass(generateAdapter = true)
200+
data class SpacesCapabilities(
201+
val enabled: Boolean,
202+
val projects: Boolean,
203+
@Json(name = "share_jail")
204+
val shareJail: Boolean,
205+
) {
206+
fun toSpaces() = RemoteSpaces(enabled, projects, shareJail)
207+
}
208+
193209
@JsonClass(generateAdapter = true)
194210
data class ServerVersion(
195211
var major: Int?,

0 commit comments

Comments
 (0)