diff --git a/dav4jvm b/dav4jvm deleted file mode 160000 index c61e4b0c8..000000000 --- a/dav4jvm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c61e4b0c80a5a8de1df99b4997445bb323d3ea3d diff --git a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java index 3aeac6a73..83a4869d9 100644 --- a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java +++ b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java @@ -128,7 +128,6 @@ public static void beforeAll() throws InterruptedException, String userId = loginName; // for test same as userId String credentials = Credentials.basic(loginName, password); nextcloudClient = new NextcloudClient(url, userId, credentials, context); - nextcloudClient.setUserId(userId); waitForServer(client, url); testConnection(); @@ -280,8 +279,8 @@ public static File extractAsset(String fileName, Context context) throws IOExcep @After public void after() { -// removeOnClient(client); -// removeOnClient(client2); + removeOnClient(client); + removeOnClient(client2); } private void removeOnClient(OwnCloudClient client) { diff --git a/library/src/androidTest/java/com/owncloud/android/Dav4JVM.kt b/library/src/androidTest/java/com/owncloud/android/Dav4JVM.kt index 8f788267d..f194a4a0b 100644 --- a/library/src/androidTest/java/com/owncloud/android/Dav4JVM.kt +++ b/library/src/androidTest/java/com/owncloud/android/Dav4JVM.kt @@ -31,10 +31,12 @@ import at.bitfire.dav4jvm.DavResource import at.bitfire.dav4jvm.Response import com.nextcloud.common.NextcloudAuthenticator import com.nextcloud.operations.PropFindMethod +import com.nextcloud.test.RandomStringGenerator import com.owncloud.android.lib.common.network.WebdavUtils import com.owncloud.android.lib.common.utils.WebDavFileUtils import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation +import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperationIT import com.owncloud.android.lib.resources.files.SearchRemoteOperation import com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation @@ -43,6 +45,9 @@ import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation import com.owncloud.android.lib.resources.shares.OCShare import com.owncloud.android.lib.resources.shares.ShareType import com.owncloud.android.lib.resources.status.OCCapability +import com.owncloud.android.lib.resources.tags.CreateTagRemoteOperation +import com.owncloud.android.lib.resources.tags.GetTagsRemoteOperation +import com.owncloud.android.lib.resources.tags.PutTagRemoteOperation import okhttp3.HttpUrl.Companion.toHttpUrl import org.apache.jackrabbit.webdav.DavConstants import org.junit.Assert.assertEquals @@ -97,14 +102,35 @@ class Dav4JVM : AbstractIT() { assertTrue(ReadFolderRemoteOperation(subFolder).execute(client).isSuccess) // do old read folder operation to compare data against it - val result = ReadFolderRemoteOperation(path).execute(client).data as List + var result = ReadFolderRemoteOperation(path).execute(client).data as List assertEquals(2, result.size) - val oldRemoteFile = result[0] - val oldSubFolderFile = result[1] + var oldRemoteFile = result[0] + var oldSubFolderFile = result[1] assertEquals(path, oldRemoteFile.remotePath) assertEquals(subFolder, oldSubFolderFile.remotePath) + // create tag + val tag1 = "a" + RandomStringGenerator.make(ReadFolderRemoteOperationIT.TAG_LENGTH) + assertTrue(CreateTagRemoteOperation(tag1).execute(nextcloudClient).isSuccess) + + // list tags + val tags = GetTagsRemoteOperation().execute(client).resultData + + // add tag + assertTrue( + PutTagRemoteOperation( + tags[0].id, + oldRemoteFile.localId + ).execute(nextcloudClient).isSuccess + ) + + // do old read folder operation to compare data against it + result = ReadFolderRemoteOperation(path).execute(client).data as List + assertEquals(2, result.size) + oldRemoteFile = result[0] + oldSubFolderFile = result[1] + // new val httpUrl = (nextcloudClient.filesDavUri.toString() + path).toHttpUrl() @@ -117,10 +143,11 @@ class Dav4JVM : AbstractIT() { val client = nextcloudClient.client .newBuilder() .followRedirects(false) - .authenticator(NextcloudAuthenticator(nextcloudClient.credentials, "Authorization")) + .authenticator(NextcloudAuthenticator(nextcloudClient.credentials)) .build() // register custom property + // TODO check how to do it in a central way WebdavUtils.registerCustomFactories() // TODO use DavResource().propfind in ReadFileRemoteOperation/ReadFolderRemoteOperation @@ -194,7 +221,11 @@ class Dav4JVM : AbstractIT() { "test", SearchRemoteOperation.SearchType.FILE_SEARCH, false, - OCCapability(23, 0, 0) + OCCapability().apply { + versionMayor = 23 + versionMinor = 0 + versionMicro = 0 + } ).execute( client ) @@ -213,7 +244,11 @@ class Dav4JVM : AbstractIT() { "test", SearchRemoteOperation.SearchType.FILE_SEARCH, false, - OCCapability(23, 0, 0) + OCCapability().apply { + versionMayor = 23 + versionMinor = 0 + versionMicro = 0 + } ).execute( nextcloudClient ) diff --git a/library/src/main/java/com/nextcloud/common/NextcloudAuthenticator.java b/library/src/main/java/com/nextcloud/common/NextcloudAuthenticator.java index e8ab3af84..c2a36ad83 100644 --- a/library/src/main/java/com/nextcloud/common/NextcloudAuthenticator.java +++ b/library/src/main/java/com/nextcloud/common/NextcloudAuthenticator.java @@ -36,17 +36,17 @@ import okhttp3.Route; public class NextcloudAuthenticator implements Authenticator { - private String credentials; - private String authenticatorType; + private final String credentials; - public NextcloudAuthenticator(@NonNull String credentials, @NonNull String authenticatorType) { + public NextcloudAuthenticator(@NonNull String credentials) { this.credentials = credentials; - this.authenticatorType = authenticatorType; } @Nullable @Override public Request authenticate(@Nullable Route route, @NonNull Response response) { + String authenticatorType = "Authorization"; + if (response.request().header(authenticatorType) != null) { return null; } diff --git a/library/src/main/java/com/nextcloud/common/NextcloudClient.kt b/library/src/main/java/com/nextcloud/common/NextcloudClient.kt index 0b42991d3..25ba86e71 100644 --- a/library/src/main/java/com/nextcloud/common/NextcloudClient.kt +++ b/library/src/main/java/com/nextcloud/common/NextcloudClient.kt @@ -122,7 +122,7 @@ class NextcloudClient private constructor( return client .newBuilder() .followRedirects(false) - .authenticator(NextcloudAuthenticator(credentials, "Authorization")) + .authenticator(NextcloudAuthenticator(credentials)) .build() } diff --git a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt index b6dcaa38b..0fb6e1c13 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt +++ b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavEntry.kt @@ -511,7 +511,7 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { } val isDirectory: Boolean - get() = "DIR" == contentType + get() = DIR_TYPE == contentType private fun resetData() { permissions = null @@ -532,6 +532,8 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { companion object { private val TAG = WebdavEntry::class.java.simpleName + private const val IS_ENCRYPTED = "1" + private const val CODE_PROP_NOT_FOUND = 404 const val NAMESPACE_OC = "http://owncloud.org/ns" const val NAMESPACE_NC = "http://nextcloud.org/ns" const val EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions" @@ -569,7 +571,6 @@ class WebdavEntry constructor(ms: MultiStatusResponse, splitElement: String) { const val SHAREES_SHARE_TYPE = "type" const val PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes" const val PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes" - private const val IS_ENCRYPTED = "1" - private const val CODE_PROP_NOT_FOUND = 404 + const val DIR_TYPE = "DIR" } } diff --git a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java index be48f615f..2f4e0d9fa 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java +++ b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java @@ -29,10 +29,6 @@ import androidx.annotation.Nullable; -import com.nextcloud.talk.components.filebrowser.models.properties.OCId; -import com.nextcloud.talk.components.filebrowser.models.properties.OCOwnerDisplayName; -import com.nextcloud.talk.components.filebrowser.models.properties.OCOwnerId; -import com.nextcloud.talk.components.filebrowser.models.properties.OCSize; import com.owncloud.android.lib.resources.files.webdav.NCEtag; import com.owncloud.android.lib.resources.files.webdav.NCFavorite; import com.owncloud.android.lib.resources.files.webdav.NCGetLastModified; @@ -40,6 +36,12 @@ import com.owncloud.android.lib.resources.files.webdav.NCPermissions; import com.owncloud.android.lib.resources.files.webdav.NCRichWorkspace; import com.owncloud.android.lib.resources.files.webdav.NCSharee; +import com.owncloud.android.lib.resources.files.webdav.NCTags; +import com.owncloud.android.lib.resources.files.webdav.OCId; +import com.owncloud.android.lib.resources.files.webdav.OCLocalId; +import com.owncloud.android.lib.resources.files.webdav.OCOwnerDisplayName; +import com.owncloud.android.lib.resources.files.webdav.OCOwnerId; +import com.owncloud.android.lib.resources.files.webdav.OCSize; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpMethod; @@ -159,6 +161,7 @@ public static DavPropertyNameSet getAllPropSet() { } public static Property.Name[] getAllPropertiesList() { + // TODO re-enable all List list = new ArrayList<>(); list.add(DisplayName.NAME); @@ -169,6 +172,7 @@ public static Property.Name[] getAllPropertiesList() { list.add(CreationDate.NAME); list.add(GetETag.NAME); // list.add(NCEtag.NAME); list.add(NCPermissions.NAME); + list.add(OCLocalId.NAME); // propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID, ocNamespace); list.add(OCSize.NAME); list.add(NCFavorite.NAME); @@ -191,6 +195,9 @@ public static Property.Name[] getAllPropertiesList() { // propSet.add(WebdavEntry.EXTENDED_PROPERTY_LOCK_TIME, ncNamespace); // propSet.add(WebdavEntry.EXTENDED_PROPERTY_LOCK_TIMEOUT, ncNamespace); // propSet.add(WebdavEntry.EXTENDED_PROPERTY_LOCK_TOKEN, ncNamespace); + list.add(NCTags.NAME); + // metadata size + // metadata gps list.add(OCId.NAME); // what about this? return list.toArray(new Property.Name[0]); @@ -340,6 +347,8 @@ public static void registerCustomFactories() { list.add(new OCOwnerDisplayName.Factory()); list.add(new NCRichWorkspace.Factory()); list.add(new NCSharee.Factory()); + list.add(new NCTags.Factory()); + list.add(new OCLocalId.Factory()); PropertyRegistry.INSTANCE.register(list); } diff --git a/library/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java index e75006217..e2e9179f6 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java @@ -444,18 +444,4 @@ public void run() { }); } } - - - /** - * Returns the current client instance to access the remote server. - * - * @return Current client instance to access the remote server. - */ - public final OwnCloudClient getClient() { - return mClient; - } - - public final NextcloudClient getClientNew() { - return clientNew; - } } diff --git a/library/src/main/java/com/owncloud/android/lib/common/utils/WebDavFileUtils.java b/library/src/main/java/com/owncloud/android/lib/common/utils/WebDavFileUtils.java index b9da3c03e..42d72a865 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/utils/WebDavFileUtils.java +++ b/library/src/main/java/com/owncloud/android/lib/common/utils/WebDavFileUtils.java @@ -29,10 +29,6 @@ import android.net.Uri; -import com.nextcloud.talk.components.filebrowser.models.properties.OCId; -import com.nextcloud.talk.components.filebrowser.models.properties.OCOwnerDisplayName; -import com.nextcloud.talk.components.filebrowser.models.properties.OCOwnerId; -import com.nextcloud.talk.components.filebrowser.models.properties.OCSize; import com.owncloud.android.lib.common.network.WebdavEntry; import com.owncloud.android.lib.resources.files.model.RemoteFile; import com.owncloud.android.lib.resources.files.webdav.NCEtag; @@ -42,6 +38,12 @@ import com.owncloud.android.lib.resources.files.webdav.NCPermissions; import com.owncloud.android.lib.resources.files.webdav.NCRichWorkspace; import com.owncloud.android.lib.resources.files.webdav.NCSharee; +import com.owncloud.android.lib.resources.files.webdav.NCTags; +import com.owncloud.android.lib.resources.files.webdav.OCId; +import com.owncloud.android.lib.resources.files.webdav.OCLocalId; +import com.owncloud.android.lib.resources.files.webdav.OCOwnerDisplayName; +import com.owncloud.android.lib.resources.files.webdav.OCOwnerId; +import com.owncloud.android.lib.resources.files.webdav.OCSize; import org.apache.jackrabbit.webdav.MultiStatus; import org.apache.jackrabbit.webdav.MultiStatusResponse; @@ -153,6 +155,10 @@ public RemoteFile parseResponse(Response response, Uri filesDavUri) { remoteFile.setSize(((OCSize) property).getOcSize()); } + if (property instanceof OCLocalId) { + remoteFile.setLocalId(((OCLocalId) property).getLocalId()); + } + if (property instanceof NCMountType) { remoteFile.setMountType(((NCMountType) property).getType()); } @@ -172,6 +178,10 @@ public RemoteFile parseResponse(Response response, Uri filesDavUri) { if (property instanceof NCSharee) { remoteFile.setSharees(((NCSharee) property).getSharees()); } + + if (property instanceof NCTags) { + remoteFile.setTags(((NCTags) property).getTags()); + } } remoteFile.setRemotePath(path); diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/SearchRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/files/SearchRemoteOperation.java index d761d379f..9a3f9f660 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/SearchRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/SearchRemoteOperation.java @@ -129,7 +129,7 @@ protected RemoteOperationResult> run(OwnCloudClient client) { Namespace.XMLNS_NAMESPACE, searchQuery), searchType, - getClient().getUserIdPlain(), + client.getUserIdPlain(), timestamp, limit, filterOutFiles, @@ -189,7 +189,7 @@ public RemoteOperationResult run(NextcloudClient client) { searchMethod = new NcSearchMethod(webDavUrl, searchInfo, searchType, - getClientNew().getUserIdPlain(), + client.getUserIdPlain(), timestamp, limit, filterOutFiles, diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCPreview.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCPreview.kt index c20d77f06..b7579c8c0 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCPreview.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCPreview.kt @@ -1,23 +1,28 @@ -/* - * Nextcloud Talk application +/* Nextcloud Android Library is available under MIT license * - * @author Mario Danic - * @author Andy Scherzinger - * Copyright (C) 2021 Andy Scherzinger - * Copyright (C) 2017-2019 Mario Danic + * @author Tobias Kaminsky + * Copyright (C) 2022 Tobias Kaminsky + * Copyright (C) 2022 Nextcloud GmbH * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * 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: * - * 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. + * 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. * - * 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.files.webdav diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCSharee.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCSharee.kt index 56c5961cc..cea5e1f3b 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCSharee.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCSharee.kt @@ -94,19 +94,22 @@ class NCSharee internal constructor(var sharees: Array) : Property { val depth = parser.depth var eventType = parser.eventType - val shareeUser = ShareeUser(null, null, null) + var userId: String? = null + var displayName: String? = null + var shareType: ShareType? = null while (!(eventType == XmlPullParser.END_TAG && parser.depth == depth)) { if (eventType != XmlPullParser.TEXT) { when (parser.propertyName().toString()) { "http://nextcloud.org/ns:id" -> { - shareeUser.userId = readText(parser) + userId = readText(parser) } + "http://nextcloud.org/ns:display-name" -> { - shareeUser.displayName = readText(parser) + displayName = readText(parser) } "http://nextcloud.org/ns:type" -> { - shareeUser.shareType = + shareType = ShareType.fromValue(readText(parser)?.toInt() ?: 0) } } @@ -115,7 +118,7 @@ class NCSharee internal constructor(var sharees: Array) : Property { eventType = parser.next() } - return shareeUser + return ShareeUser(userId, displayName, shareType) } } } diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCTags.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCTags.kt new file mode 100644 index 000000000..df7a01761 --- /dev/null +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCTags.kt @@ -0,0 +1,128 @@ +/* + * Nextcloud Android client application + * + * @author Tobias Kaminsky + * Copyright (C) 2022 Tobias Kaminsky + * Copyright (C) 2022 Nextcloud GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +package com.owncloud.android.lib.resources.files.webdav + +import android.text.TextUtils +import androidx.annotation.VisibleForTesting +import at.bitfire.dav4jvm.Property +import at.bitfire.dav4jvm.PropertyFactory +import at.bitfire.dav4jvm.XmlUtils.propertyName +import at.bitfire.dav4jvm.XmlUtils.readText +import com.owncloud.android.lib.common.network.WebdavEntry +import com.owncloud.android.lib.resources.shares.ShareType +import org.xmlpull.v1.XmlPullParser +import org.xmlpull.v1.XmlPullParserException +import java.io.IOException + +class NCTags internal constructor(var tags: Array) : Property { + + companion object { + @JvmField + val NAME = + Property.Name(WebdavEntry.NAMESPACE_NC, WebdavEntry.EXTENDED_PROPERTY_SYSTEM_TAGS) + } + + class Factory : PropertyFactory { + + override fun getName() = NAME + + override fun create(parser: XmlPullParser): NCTags { + // NC sharees property + readArrayNode(parser).let { sharees -> + return NCTags(sharees.toTypedArray()) + } + } + + @Throws(IOException::class, XmlPullParserException::class) + @VisibleForTesting + fun readArrayNode(parser: XmlPullParser): List { + var list: List = emptyList() + + val depth = parser.depth + var eventType = parser.eventType + while (!(eventType == XmlPullParser.END_TAG && parser.depth == depth)) { + if (eventType != XmlPullParser.TEXT) { + list = readNCSharees(parser) + } + if (parser.eventType == XmlPullParser.END_TAG && parser.depth == depth) { + return list + } + + eventType = parser.next() + } + + return list + } + + private fun readNCSharees(parser: XmlPullParser): List { + val list: ArrayList = ArrayList() + + val depth = parser.depth + var eventType = parser.eventType + while (!(eventType == XmlPullParser.END_TAG && parser.depth == depth)) { + if (eventType == XmlPullParser.START_TAG && parser.depth == depth + 1) { + list.add(readNCSharee(parser)) + } + + eventType = parser.next() + } + + return list + } + + private fun readNCSharee(parser: XmlPullParser): String { + val depth = parser.depth + var eventType = parser.eventType + + var userId: String? = null + var displayName: String? = null + var shareType: ShareType? = null + + while (!(eventType == XmlPullParser.END_TAG && parser.depth == depth)) { + if (eventType != XmlPullParser.TEXT) { + when (parser.propertyName().toString()) { + "http://nextcloud.org/ns:id" -> { + userId = readText(parser) + } + + "http://nextcloud.org/ns:display-name" -> { + displayName = readText(parser) + } + + "http://nextcloud.org/ns:type" -> { + shareType = + ShareType.fromValue(readText(parser)?.toInt() ?: 0) + } + } + } + + if (!TextUtils.isEmpty(parser.text)) { + return parser.text + } + eventType = parser.next() + } + + return "" + } + } +} diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCId.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCId.kt index a1d2535b7..49573295b 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCId.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCId.kt @@ -1,26 +1,31 @@ -/* - * Nextcloud Talk application +/* Nextcloud Android Library is available under MIT license * - * @author Mario Danic - * @author Andy Scherzinger - * Copyright (C) 2021 Andy Scherzinger - * Copyright (C) 2017-2019 Mario Danic + * @author Tobias Kaminsky + * Copyright (C) 2022 Tobias Kaminsky + * Copyright (C) 2022 Nextcloud GmbH * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * 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: * - * 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. + * 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. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ -package com.nextcloud.talk.components.filebrowser.models.properties +package com.owncloud.android.lib.resources.files.webdav import android.text.TextUtils import android.util.Log diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCLocalId.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCLocalId.kt new file mode 100644 index 000000000..3d7efc32a --- /dev/null +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCLocalId.kt @@ -0,0 +1,67 @@ +/* Nextcloud Android Library is available under MIT license + * + * @author Tobias Kaminsky + * Copyright (C) 2022 Tobias Kaminsky + * Copyright (C) 2022 Nextcloud GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * 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 + * 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.files.webdav + +import android.text.TextUtils +import android.util.Log +import at.bitfire.dav4jvm.Property +import at.bitfire.dav4jvm.PropertyFactory +import at.bitfire.dav4jvm.XmlUtils.readText +import com.owncloud.android.lib.common.network.WebdavEntry +import org.xmlpull.v1.XmlPullParser +import org.xmlpull.v1.XmlPullParserException +import java.io.IOException + +class OCLocalId private constructor(var localId: Long) : Property { + + class Factory : PropertyFactory { + override fun create(parser: XmlPullParser): Property { + try { + val text = readText(parser) + if (!TextUtils.isEmpty(text)) { + return OCLocalId(text!!.toLong()) + } + } catch (e: IOException) { + Log.e("OCLocalId", "failed to create property", e) + } catch (e: XmlPullParserException) { + Log.e("OCLocalId", "failed to create property", e) + } + return OCLocalId(-1) + } + + override fun getName(): Property.Name { + return NAME + } + } + + companion object { + @JvmField + val NAME: Property.Name = + Property.Name(WebdavEntry.NAMESPACE_OC, WebdavEntry.EXTENDED_PROPERTY_NAME_LOCAL_ID) + } +} diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerDisplayName.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerDisplayName.kt index 9551c6857..1292f9a1a 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerDisplayName.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerDisplayName.kt @@ -1,26 +1,31 @@ -/* - * Nextcloud Talk application +/* Nextcloud Android Library is available under MIT license * - * @author Mario Danic - * @author Andy Scherzinger - * Copyright (C) 2021 Andy Scherzinger - * Copyright (C) 2017-2019 Mario Danic + * @author Tobias Kaminsky + * Copyright (C) 2022 Tobias Kaminsky + * Copyright (C) 2022 Nextcloud GmbH * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * 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: * - * 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. + * 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. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ -package com.nextcloud.talk.components.filebrowser.models.properties +package com.owncloud.android.lib.resources.files.webdav import android.text.TextUtils import android.util.Log diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerId.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerId.kt index 32df45b21..398ee7ee6 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerId.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCOwnerId.kt @@ -1,26 +1,31 @@ -/* - * Nextcloud Talk application +/* Nextcloud Android Library is available under MIT license * - * @author Mario Danic - * @author Andy Scherzinger - * Copyright (C) 2021 Andy Scherzinger - * Copyright (C) 2017-2019 Mario Danic + * @author Tobias Kaminsky + * Copyright (C) 2022 Tobias Kaminsky + * Copyright (C) 2022 Nextcloud GmbH * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * 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: * - * 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. + * 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. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ -package com.nextcloud.talk.components.filebrowser.models.properties +package com.owncloud.android.lib.resources.files.webdav import android.text.TextUtils import android.util.Log diff --git a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCSize.kt b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCSize.kt index 7f41c39b3..ed235c88a 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCSize.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/files/webdav/OCSize.kt @@ -1,26 +1,31 @@ -/* - * Nextcloud Talk application +/* Nextcloud Android Library is available under MIT license * - * @author Mario Danic - * @author Andy Scherzinger - * Copyright (C) 2021 Andy Scherzinger - * Copyright (C) 2017-2019 Mario Danic + * @author Tobias Kaminsky + * Copyright (C) 2022 Tobias Kaminsky + * Copyright (C) 2022 Nextcloud GmbH * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * 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: * - * 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. + * 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. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ -package com.nextcloud.talk.components.filebrowser.models.properties +package com.owncloud.android.lib.resources.files.webdav import android.text.TextUtils import android.util.Log diff --git a/library/src/main/java/com/owncloud/android/lib/resources/shares/ShareeUser.kt b/library/src/main/java/com/owncloud/android/lib/resources/shares/ShareeUser.kt index 66068d7b8..e30a6ad8d 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/shares/ShareeUser.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/shares/ShareeUser.kt @@ -32,5 +32,3 @@ import kotlinx.parcelize.Parcelize @Parcelize data class ShareeUser(val userId: String?, var displayName: String?, val shareType: ShareType?) : Parcelable -data class ShareeUser(var userId: String?, var displayName: String?, var shareType: ShareType?) : - Parcelable diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt index 79bdcc3a7..b5b34d9b5 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt @@ -27,15 +27,14 @@ package com.owncloud.android.lib.resources.status /** * Contains data of the Capabilities for an account, from the Capabilities API */ -class OCCapability( - var versionMayor: Int = 0, - var versionMinor: Int = 0, - var versionMicro: Int = 0 -) { +class OCCapability { var id: Long = 0 var accountName: String? = "" // Server version + var versionMayor = 0 + var versionMinor = 0 + var versionMicro = 0 var versionString: String? = "" var versionEdition: String? = null