mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Save spaces-related capabilities in database
This commit is contained in:
		
							parent
							
								
									defa4d1469
								
							
						
					
					
						commit
						419ee9ca77
					
				| @ -45,7 +45,7 @@ import java.net.URL | |||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Get the Capabilities from the server |  * Get the Capabilities from the server | ||||||
|  * Save in Result.getData in a RemoteCapability object |  * Save Result.getData in a RemoteCapability object | ||||||
|  * |  * | ||||||
|  * @author masensio |  * @author masensio | ||||||
|  * @author David González Verdugo |  * @author David González Verdugo | ||||||
|  | |||||||
| @ -1,29 +1,33 @@ | |||||||
| /* ownCloud Android Library is available under MIT license | /** | ||||||
|  *   @author masensio |  * ownCloud Android Library is available under MIT license | ||||||
|  *   @author David González Verdugo |  | ||||||
|  *   @author Abel García de Prada |  | ||||||
|  *   Copyright (C) 2020 ownCloud GmbH. |  | ||||||
|  * |  * | ||||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy |  * @author masensio | ||||||
|  *   of this software and associated documentation files (the "Software"), to deal |  * @author David González Verdugo | ||||||
|  *   in the Software without restriction, including without limitation the rights |  * @author Abel García de Prada | ||||||
|  *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |  * @author Juan Carlos Garrote Gascón | ||||||
|  *   copies of the Software, and to permit persons to whom the Software is |  | ||||||
|  *   furnished to do so, subject to the following conditions: |  | ||||||
|  * |  * | ||||||
|  *   The above copyright notice and this permission notice shall be included in |  * Copyright (C) 2022 ownCloud GmbH. | ||||||
|  *   all copies or substantial portions of the Software. |  | ||||||
|  * |  * | ||||||
|  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
|  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |  * of this software and associated documentation files (the "Software"), to deal | ||||||
|  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |  * in the Software without restriction, including without limitation the rights | ||||||
|  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||
|  *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |  * copies of the Software, and to permit persons to whom the Software is | ||||||
|  *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |  * furnished to do so, subject to the following conditions: | ||||||
|  *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |  | ||||||
|  *   THE SOFTWARE. |  | ||||||
|  * |  * | ||||||
|  |  * The above copyright notice and this permission notice shall be included in | ||||||
|  |  * all copies or substantial portions of the Software. | ||||||
|  |  * | ||||||
|  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||||
|  |  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||||
|  |  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||||
|  |  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||||||
|  |  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||||||
|  |  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||||||
|  |  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||||
|  |  * THE SOFTWARE. | ||||||
|  */ |  */ | ||||||
|  | 
 | ||||||
| package com.owncloud.android.lib.resources.status | package com.owncloud.android.lib.resources.status | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -33,7 +37,7 @@ data class RemoteCapability( | |||||||
|     var accountName: String = "", |     var accountName: String = "", | ||||||
| 
 | 
 | ||||||
|     // Server version |     // Server version | ||||||
|     var versionMayor: Int = 0, |     var versionMajor: Int = 0, | ||||||
|     var versionMinor: Int = 0, |     var versionMinor: Int = 0, | ||||||
|     var versionMicro: Int = 0, |     var versionMicro: Int = 0, | ||||||
|     var versionString: String = "", |     var versionString: String = "", | ||||||
| @ -68,7 +72,10 @@ data class RemoteCapability( | |||||||
|     var filesUndelete: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN, |     var filesUndelete: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN, | ||||||
|     var filesVersioning: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN, |     var filesVersioning: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN, | ||||||
|     val filesPrivateLinks: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN, |     val filesPrivateLinks: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN, | ||||||
|     val filesAppProviders: List<RemoteOCISProvider>?, |     val filesAppProviders: List<RemoteAppProviders>?, | ||||||
|  | 
 | ||||||
|  |     // Spaces | ||||||
|  |     val spaces: RemoteSpaces?, | ||||||
| ) { | ) { | ||||||
|     /** |     /** | ||||||
|      * Enum for Boolean Type in capabilities, with values: |      * Enum for Boolean Type in capabilities, with values: | ||||||
| @ -101,7 +108,7 @@ data class RemoteCapability( | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     data class RemoteOCISProvider( |     data class RemoteAppProviders( | ||||||
|         val enabled: Boolean, |         val enabled: Boolean, | ||||||
|         val version: String, |         val version: String, | ||||||
|         val appsUrl: String?, |         val appsUrl: String?, | ||||||
| @ -109,4 +116,10 @@ data class RemoteCapability( | |||||||
|         val openWebUrl: String?, |         val openWebUrl: String?, | ||||||
|         val newUrl: String?, |         val newUrl: String?, | ||||||
|     ) |     ) | ||||||
|  | 
 | ||||||
|  |     data class RemoteSpaces( | ||||||
|  |         val enabled: Boolean, | ||||||
|  |         val projects: Boolean, | ||||||
|  |         val shareJail: Boolean, | ||||||
|  |     ) | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,32 +1,35 @@ | |||||||
| /* ownCloud Android Library is available under MIT license | /** | ||||||
|  *   @author Abel García de Prada |  * ownCloud Android Library is available under MIT license | ||||||
|  *   Copyright (C) 2020 ownCloud GmbH. |  | ||||||
|  * |  * | ||||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy |  * @author Abel García de Prada | ||||||
|  *   of this software and associated documentation files (the "Software"), to deal |  * @author Juan Carlos Garrote Gascón | ||||||
|  *   in the Software without restriction, including without limitation the rights |  | ||||||
|  *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |  | ||||||
|  *   copies of the Software, and to permit persons to whom the Software is |  | ||||||
|  *   furnished to do so, subject to the following conditions: |  | ||||||
|  * |  * | ||||||
|  *   The above copyright notice and this permission notice shall be included in |  * Copyright (C) 2022 ownCloud GmbH. | ||||||
|  *   all copies or substantial portions of the Software. |  | ||||||
|  * |  * | ||||||
|  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
|  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |  * of this software and associated documentation files (the "Software"), to deal | ||||||
|  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |  * in the Software without restriction, including without limitation the rights | ||||||
|  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||
|  *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |  * copies of the Software, and to permit persons to whom the Software is | ||||||
|  *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |  * furnished to do so, subject to the following conditions: | ||||||
|  *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |  | ||||||
|  *   THE SOFTWARE. |  | ||||||
|  * |  * | ||||||
|  |  * The above copyright notice and this permission notice shall be included in | ||||||
|  |  * all copies or substantial portions of the Software. | ||||||
|  |  * | ||||||
|  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||||
|  |  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||||
|  |  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||||
|  |  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||||||
|  |  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||||||
|  |  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||||||
|  |  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||||
|  |  * THE SOFTWARE. | ||||||
|  */ |  */ | ||||||
|  | 
 | ||||||
| package com.owncloud.android.lib.resources.status.responses | package com.owncloud.android.lib.resources.status.responses | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.resources.status.RemoteCapability | import com.owncloud.android.lib.resources.status.RemoteCapability | ||||||
| import com.owncloud.android.lib.resources.status.RemoteCapability.CapabilityBooleanType | import com.owncloud.android.lib.resources.status.RemoteCapability.* | ||||||
| import com.owncloud.android.lib.resources.status.RemoteCapability.RemoteOCISProvider |  | ||||||
| import com.squareup.moshi.Json | import com.squareup.moshi.Json | ||||||
| import com.squareup.moshi.JsonClass | import com.squareup.moshi.JsonClass | ||||||
| 
 | 
 | ||||||
| @ -37,7 +40,7 @@ data class CapabilityResponse( | |||||||
|     val capabilities: Capabilities? |     val capabilities: Capabilities? | ||||||
| ) { | ) { | ||||||
|     fun toRemoteCapability(): RemoteCapability = RemoteCapability( |     fun toRemoteCapability(): RemoteCapability = RemoteCapability( | ||||||
|         versionMayor = serverVersion?.major ?: 0, |         versionMajor = serverVersion?.major ?: 0, | ||||||
|         versionMinor = serverVersion?.minor ?: 0, |         versionMinor = serverVersion?.minor ?: 0, | ||||||
|         versionMicro = serverVersion?.micro ?: 0, |         versionMicro = serverVersion?.micro ?: 0, | ||||||
|         versionString = serverVersion?.string ?: "", |         versionString = serverVersion?.string ?: "", | ||||||
| @ -70,10 +73,11 @@ data class CapabilityResponse( | |||||||
|         filesUndelete = CapabilityBooleanType.fromBooleanValue(capabilities?.fileCapabilities?.undelete), |         filesUndelete = CapabilityBooleanType.fromBooleanValue(capabilities?.fileCapabilities?.undelete), | ||||||
|         filesVersioning = CapabilityBooleanType.fromBooleanValue(capabilities?.fileCapabilities?.versioning), |         filesVersioning = CapabilityBooleanType.fromBooleanValue(capabilities?.fileCapabilities?.versioning), | ||||||
|         filesPrivateLinks = capabilities?.fileCapabilities?.privateLinks?.let { CapabilityBooleanType.fromBooleanValue(it) } ?: CapabilityBooleanType.UNKNOWN, |         filesPrivateLinks = capabilities?.fileCapabilities?.privateLinks?.let { CapabilityBooleanType.fromBooleanValue(it) } ?: CapabilityBooleanType.UNKNOWN, | ||||||
|         filesAppProviders = capabilities?.fileCapabilities?.appProviders?.map { it.toOCISProvider() }, |         filesAppProviders = capabilities?.fileCapabilities?.appProviders?.map { it.toAppProviders() }, | ||||||
|         filesSharingFederationIncoming = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingFederation?.incoming), |         filesSharingFederationIncoming = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingFederation?.incoming), | ||||||
|         filesSharingFederationOutgoing = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingFederation?.outgoing), |         filesSharingFederationOutgoing = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingFederation?.outgoing), | ||||||
|         filesSharingUserProfilePicture = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingUser?.profilePicture), |         filesSharingUserProfilePicture = CapabilityBooleanType.fromBooleanValue(capabilities?.fileSharingCapabilities?.fileSharingUser?.profilePicture), | ||||||
|  |         spaces = capabilities?.spacesCapabilities?.toSpaces(), | ||||||
|     ) |     ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -86,7 +90,9 @@ data class Capabilities( | |||||||
|     @Json(name = "files") |     @Json(name = "files") | ||||||
|     val fileCapabilities: FileCapabilities?, |     val fileCapabilities: FileCapabilities?, | ||||||
|     @Json(name = "dav") |     @Json(name = "dav") | ||||||
|     val davCapabilities: DavCapabilities? |     val davCapabilities: DavCapabilities?, | ||||||
|  |     @Json(name = "spaces") | ||||||
|  |     val spacesCapabilities: SpacesCapabilities? | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| @JsonClass(generateAdapter = true) | @JsonClass(generateAdapter = true) | ||||||
| @ -182,7 +188,7 @@ data class AppProvider( | |||||||
|     @Json(name = "new_url") |     @Json(name = "new_url") | ||||||
|     val newUrl: String?, |     val newUrl: String?, | ||||||
| ) { | ) { | ||||||
|     fun toOCISProvider() = RemoteOCISProvider(enabled, version, appsUrl, openUrl, openWebUrl, newUrl) |     fun toAppProviders() = RemoteAppProviders(enabled, version, appsUrl, openUrl, openWebUrl, newUrl) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @JsonClass(generateAdapter = true) | @JsonClass(generateAdapter = true) | ||||||
| @ -190,6 +196,16 @@ data class DavCapabilities( | |||||||
|     val chunking: String? |     val chunking: String? | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | @JsonClass(generateAdapter = true) | ||||||
|  | data class SpacesCapabilities( | ||||||
|  |     val enabled: Boolean, | ||||||
|  |     val projects: Boolean, | ||||||
|  |     @Json(name = "share_jail") | ||||||
|  |     val shareJail: Boolean, | ||||||
|  | ) { | ||||||
|  |     fun toSpaces() = RemoteSpaces(enabled, projects, shareJail) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| @JsonClass(generateAdapter = true) | @JsonClass(generateAdapter = true) | ||||||
| data class ServerVersion( | data class ServerVersion( | ||||||
|     var major: Int?, |     var major: Int?, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user