mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
wip
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
63aec8ff46
commit
349bf1aa54
@ -311,6 +311,10 @@ dependencies {
|
||||
implementation 'com.github.nextcloud.android-common:ui:0.12.0'
|
||||
|
||||
implementation 'com.github.nextcloud-deps:android-talk-webrtc:110.5481.0'
|
||||
|
||||
implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
|
||||
}
|
||||
}
|
||||
|
||||
task installGitHooks(type: Copy, group: "development") {
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.nextcloud.talk.components.filebrowser.webdav
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.talk.components.filebrowser.models.BrowserFile
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import junit.framework.Assert.assertEquals
|
||||
import okhttp3.OkHttpClient
|
||||
import org.junit.Test
|
||||
|
||||
class ReadFilesystemOperationIT {
|
||||
@Test
|
||||
fun showContent() {
|
||||
val arguments = InstrumentationRegistry.getArguments()
|
||||
val url = Uri.parse(arguments.getString("TEST_SERVER_URL"))
|
||||
val username = arguments.getString("TEST_SERVER_USERNAME")
|
||||
val password = arguments.getString("TEST_SERVER_PASSWORD")
|
||||
|
||||
val client = OkHttpClient()
|
||||
val user = User().apply {
|
||||
baseUrl = url.toString()
|
||||
userId = username
|
||||
this.username = username
|
||||
token = password
|
||||
}
|
||||
val sut = ReadFilesystemOperation(client, user, "", 1)
|
||||
val data = sut.readRemotePath().data as List<BrowserFile>
|
||||
assertEquals(1, data.size)
|
||||
}
|
||||
}
|
@ -50,7 +50,6 @@ import coil.decode.SvgDecoder
|
||||
import coil.memory.MemoryCache
|
||||
import coil.util.DebugLogger
|
||||
import com.nextcloud.talk.BuildConfig
|
||||
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import com.nextcloud.talk.dagger.modules.BusModule
|
||||
import com.nextcloud.talk.dagger.modules.ContextModule
|
||||
import com.nextcloud.talk.dagger.modules.DatabaseModule
|
||||
@ -70,6 +69,7 @@ import com.nextcloud.talk.utils.database.arbitrarystorage.ArbitraryStorageModule
|
||||
import com.nextcloud.talk.utils.database.user.UserModule
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||
import com.nextcloud.talk.webrtc.MagicWebRTCUtils
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils
|
||||
import com.vanniktech.emoji.EmojiManager
|
||||
import com.vanniktech.emoji.google.GoogleEmojiProvider
|
||||
import de.cotech.hw.SecurityKeyManager
|
||||
@ -164,7 +164,7 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver {
|
||||
|
||||
initializeWebRtc()
|
||||
buildComponent()
|
||||
DavUtils.registerCustomFactories()
|
||||
WebdavUtils.registerCustomFactories()
|
||||
|
||||
componentApplication.inject(this)
|
||||
|
||||
|
@ -30,13 +30,13 @@ import at.bitfire.dav4jvm.property.GetLastModified
|
||||
import at.bitfire.dav4jvm.property.ResourceType
|
||||
import at.bitfire.dav4jvm.property.ResourceType.Companion.COLLECTION
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCEncrypted
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPermission
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPreview
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCFavorite
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCId
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCSize
|
||||
import com.nextcloud.talk.utils.Mimetype.FOLDER
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCEncrypted
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCFavorite
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCPermissions
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCPreview
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import java.io.File
|
||||
|
||||
@ -101,7 +101,7 @@ data class BrowserFile(
|
||||
is NCPreview -> {
|
||||
browserFile.hasPreview = property.isNcPreview
|
||||
}
|
||||
is OCFavorite -> {
|
||||
is NCFavorite -> {
|
||||
browserFile.isFavorite = property.isOcFavorite
|
||||
}
|
||||
is DisplayName -> {
|
||||
@ -110,8 +110,8 @@ data class BrowserFile(
|
||||
is NCEncrypted -> {
|
||||
browserFile.isEncrypted = property.isNcEncrypted
|
||||
}
|
||||
is NCPermission -> {
|
||||
browserFile.permissions = property.ncPermission
|
||||
is NCPermissions -> {
|
||||
browserFile.permissions = property.permissions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.nextcloud.talk.components.filebrowser.models.properties
|
||||
|
||||
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.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
import java.io.IOException
|
||||
|
||||
class NCEncrypted private constructor(var isNcEncrypted: Boolean) : Property {
|
||||
|
||||
class Factory : PropertyFactory {
|
||||
override fun create(parser: XmlPullParser): Property {
|
||||
try {
|
||||
val text = readText(parser)
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
return NCEncrypted("1" == text)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("NCEncrypted", "failed to create property", e)
|
||||
} catch (e: XmlPullParserException) {
|
||||
Log.e("NCEncrypted", "failed to create property", e)
|
||||
}
|
||||
return NCEncrypted(false)
|
||||
}
|
||||
|
||||
override fun getName(): Property.Name {
|
||||
return NAME
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val NAME: Property.Name = Property.Name(DavUtils.NC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_IS_ENCRYPTED)
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Marcel Hibbe
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.nextcloud.talk.components.filebrowser.models.properties
|
||||
|
||||
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.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
import java.io.IOException
|
||||
|
||||
class NCPermission private constructor(var ncPermission: String?) : Property {
|
||||
|
||||
class Factory : PropertyFactory {
|
||||
override fun create(parser: XmlPullParser): Property {
|
||||
try {
|
||||
val text = readText(parser)
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
return NCPermission(text)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("NCPermission", "failed to create property", e)
|
||||
} catch (e: XmlPullParserException) {
|
||||
Log.e("NCPermission", "failed to create property", e)
|
||||
}
|
||||
return NCPermission("")
|
||||
}
|
||||
|
||||
override fun getName(): Property.Name {
|
||||
return NAME
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val NAME: Property.Name = Property.Name(DavUtils.OC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_NAME_PERMISSIONS)
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.nextcloud.talk.components.filebrowser.models.properties
|
||||
|
||||
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.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
import java.io.IOException
|
||||
|
||||
class NCPreview private constructor(var isNcPreview: Boolean) : Property {
|
||||
|
||||
class Factory : PropertyFactory {
|
||||
override fun create(parser: XmlPullParser): Property {
|
||||
try {
|
||||
val text = readText(parser)
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
return NCPreview(java.lang.Boolean.parseBoolean(text))
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("NCPreview", "failed to create property", e)
|
||||
} catch (e: XmlPullParserException) {
|
||||
Log.e("NCPreview", "failed to create property", e)
|
||||
}
|
||||
return OCFavorite(false)
|
||||
}
|
||||
|
||||
override fun getName(): Property.Name {
|
||||
return NAME
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val NAME: Property.Name = Property.Name(DavUtils.NC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_HAS_PREVIEW)
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.nextcloud.talk.components.filebrowser.models.properties
|
||||
|
||||
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.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
import java.io.IOException
|
||||
|
||||
class OCFavorite internal constructor(var isOcFavorite: Boolean) : Property {
|
||||
|
||||
class Factory : PropertyFactory {
|
||||
override fun create(parser: XmlPullParser): Property {
|
||||
try {
|
||||
val text = readText(parser)
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
return OCFavorite("1" == text)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("OCFavorite", "failed to create property", e)
|
||||
} catch (e: XmlPullParserException) {
|
||||
Log.e("OCFavorite", "failed to create property", e)
|
||||
}
|
||||
return OCFavorite(false)
|
||||
}
|
||||
|
||||
override fun getName(): Property.Name {
|
||||
return NAME
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val NAME: Property.Name = Property.Name(DavUtils.OC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_FAVORITE)
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.nextcloud.talk.components.filebrowser.models.properties
|
||||
|
||||
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.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
import java.io.IOException
|
||||
|
||||
class OCId private constructor(var ocId: String?) : Property {
|
||||
|
||||
class Factory : PropertyFactory {
|
||||
override fun create(parser: XmlPullParser): Property {
|
||||
try {
|
||||
val text = readText(parser)
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
return OCId(text)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("OCId", "failed to create property", e)
|
||||
} catch (e: XmlPullParserException) {
|
||||
Log.e("OCId", "failed to create property", e)
|
||||
}
|
||||
return OCId("")
|
||||
}
|
||||
|
||||
override fun getName(): Property.Name {
|
||||
return NAME
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val NAME: Property.Name = Property.Name(DavUtils.OC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_NAME_REMOTE_ID)
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.nextcloud.talk.components.filebrowser.models.properties
|
||||
|
||||
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.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
import java.io.IOException
|
||||
|
||||
class OCSize private constructor(var ocSize: Long) : Property {
|
||||
|
||||
class Factory : PropertyFactory {
|
||||
override fun create(parser: XmlPullParser): Property {
|
||||
try {
|
||||
val text = readText(parser)
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
return OCSize(text!!.toLong())
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("OCSize", "failed to create property", e)
|
||||
} catch (e: XmlPullParserException) {
|
||||
Log.e("OCSize", "failed to create property", e)
|
||||
}
|
||||
return OCSize(-1)
|
||||
}
|
||||
|
||||
override fun getName(): Property.Name {
|
||||
return NAME
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val NAME: Property.Name = Property.Name(DavUtils.OC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_NAME_SIZE)
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.nextcloud.talk.components.filebrowser.webdav;
|
||||
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCEncrypted;
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPermission;
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPreview;
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCFavorite;
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCId;
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCSize;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import at.bitfire.dav4jvm.Property;
|
||||
import at.bitfire.dav4jvm.PropertyRegistry;
|
||||
import at.bitfire.dav4jvm.property.CreationDate;
|
||||
import at.bitfire.dav4jvm.property.DisplayName;
|
||||
import at.bitfire.dav4jvm.property.GetContentLength;
|
||||
import at.bitfire.dav4jvm.property.GetContentType;
|
||||
import at.bitfire.dav4jvm.property.GetETag;
|
||||
import at.bitfire.dav4jvm.property.GetLastModified;
|
||||
import at.bitfire.dav4jvm.property.ResourceType;
|
||||
|
||||
public class DavUtils {
|
||||
|
||||
public static final String OC_NAMESPACE = "http://owncloud.org/ns";
|
||||
public static final String NC_NAMESPACE = "http://nextcloud.org/ns";
|
||||
public static final String DAV_PATH = "/remote.php/dav/files/";
|
||||
|
||||
public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions";
|
||||
public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id";
|
||||
public static final String EXTENDED_PROPERTY_NAME_SIZE = "size";
|
||||
public static final String EXTENDED_PROPERTY_FAVORITE = "favorite";
|
||||
public static final String EXTENDED_PROPERTY_IS_ENCRYPTED = "is-encrypted";
|
||||
public static final String EXTENDED_PROPERTY_MOUNT_TYPE = "mount-type";
|
||||
public static final String EXTENDED_PROPERTY_OWNER_ID = "owner-id";
|
||||
public static final String EXTENDED_PROPERTY_OWNER_DISPLAY_NAME = "owner-display-name";
|
||||
public static final String EXTENDED_PROPERTY_UNREAD_COMMENTS = "comments-unread";
|
||||
public static final String EXTENDED_PROPERTY_HAS_PREVIEW = "has-preview";
|
||||
public static final String EXTENDED_PROPERTY_NOTE = "note";
|
||||
|
||||
// public static final String TRASHBIN_FILENAME = "trashbin-filename";
|
||||
// public static final String TRASHBIN_ORIGINAL_LOCATION = "trashbin-original-location";
|
||||
// public static final String TRASHBIN_DELETION_TIME = "trashbin-deletion-time";
|
||||
|
||||
// public static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes";
|
||||
// public static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes";
|
||||
|
||||
static Property.Name[] getAllPropSet() {
|
||||
List<Property.Name> props = new ArrayList<>(20);
|
||||
|
||||
props.add(DisplayName.NAME);
|
||||
props.add(GetContentType.NAME);
|
||||
props.add(GetContentLength.NAME);
|
||||
props.add(GetContentType.NAME);
|
||||
props.add(GetContentLength.NAME);
|
||||
props.add(GetLastModified.NAME);
|
||||
props.add(CreationDate.NAME);
|
||||
props.add(GetETag.NAME);
|
||||
props.add(ResourceType.NAME);
|
||||
|
||||
props.add(NCPermission.NAME);
|
||||
props.add(OCId.NAME);
|
||||
props.add(OCSize.NAME);
|
||||
props.add(OCFavorite.NAME);
|
||||
props.add(new Property.Name(OC_NAMESPACE, EXTENDED_PROPERTY_OWNER_ID));
|
||||
props.add(new Property.Name(OC_NAMESPACE, EXTENDED_PROPERTY_OWNER_DISPLAY_NAME));
|
||||
props.add(new Property.Name(OC_NAMESPACE, EXTENDED_PROPERTY_UNREAD_COMMENTS));
|
||||
|
||||
props.add(NCEncrypted.NAME);
|
||||
props.add(new Property.Name(NC_NAMESPACE, EXTENDED_PROPERTY_MOUNT_TYPE));
|
||||
props.add(NCPreview.NAME);
|
||||
props.add(new Property.Name(NC_NAMESPACE, EXTENDED_PROPERTY_NOTE));
|
||||
|
||||
return props.toArray(new Property.Name[0]);
|
||||
}
|
||||
|
||||
public static void registerCustomFactories() {
|
||||
PropertyRegistry propertyRegistry = PropertyRegistry.INSTANCE;
|
||||
|
||||
propertyRegistry.register(new OCId.Factory());
|
||||
propertyRegistry.register(new NCPreview.Factory());
|
||||
propertyRegistry.register(new NCEncrypted.Factory());
|
||||
propertyRegistry.register(new OCFavorite.Factory());
|
||||
propertyRegistry.register(new OCSize.Factory());
|
||||
propertyRegistry.register(new NCPermission.Factory());
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
|
||||
package com.nextcloud.talk.components.filebrowser.webdav;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nextcloud.talk.components.filebrowser.models.BrowserFile;
|
||||
@ -27,6 +28,9 @@ import com.nextcloud.talk.components.filebrowser.models.DavResponse;
|
||||
import com.nextcloud.talk.dagger.modules.RestModule;
|
||||
import com.nextcloud.talk.data.user.model.User;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||
import com.owncloud.android.lib.common.utils.WebDavFileUtils;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -60,7 +64,7 @@ public class ReadFilesystemOperation {
|
||||
"Authorization")
|
||||
);
|
||||
this.okHttpClient = okHttpClientBuilder.build();
|
||||
this.basePath = currentUser.getBaseUrl() + DavUtils.DAV_PATH + currentUser.getUserId();
|
||||
this.basePath = currentUser.getBaseUrl() + ApiUtils.filesApi + currentUser.getUserId();
|
||||
this.url = basePath + path;
|
||||
this.depth = depth;
|
||||
}
|
||||
@ -69,36 +73,46 @@ public class ReadFilesystemOperation {
|
||||
DavResponse davResponse = new DavResponse();
|
||||
final List<Response> memberElements = new ArrayList<>();
|
||||
final Response[] rootElement = new Response[1];
|
||||
final List<BrowserFile> browserFiles = new ArrayList<>();
|
||||
final List<RemoteFile> remoteFiles = new ArrayList<>();
|
||||
|
||||
try {
|
||||
new DavResource(okHttpClient, HttpUrl.parse(url)).propfind(depth, DavUtils.getAllPropSet(),
|
||||
new Function2<Response, Response.HrefRelation, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(Response response, Response.HrefRelation hrefRelation) {
|
||||
davResponse.setResponse(response);
|
||||
switch (hrefRelation) {
|
||||
case MEMBER:
|
||||
memberElements.add(response);
|
||||
break;
|
||||
case SELF:
|
||||
rootElement[0] = response;
|
||||
break;
|
||||
case OTHER:
|
||||
default:
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
});
|
||||
new DavResource(okHttpClient, HttpUrl.parse(url)).propfind(depth, WebdavUtils.getAllPropertiesList(),
|
||||
new Function2<Response, Response.HrefRelation, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(Response response, Response.HrefRelation hrefRelation) {
|
||||
davResponse.setResponse(response);
|
||||
switch (hrefRelation) {
|
||||
case MEMBER:
|
||||
memberElements.add(response);
|
||||
break;
|
||||
case SELF:
|
||||
rootElement[0] = response;
|
||||
break;
|
||||
case OTHER:
|
||||
default:
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
});
|
||||
} catch (IOException | DavException e) {
|
||||
Log.w(TAG, "Error reading remote path");
|
||||
}
|
||||
|
||||
final List<BrowserFile> remoteFiles = new ArrayList<>(1 + memberElements.size());
|
||||
remoteFiles.add(BrowserFile.Companion.getModelFromResponse(rootElement[0],
|
||||
rootElement[0].getHref().toString().substring(basePath.length())));
|
||||
WebDavFileUtils webDavFileUtils = new WebDavFileUtils();
|
||||
|
||||
browserFiles.add(BrowserFile.Companion.getModelFromResponse(rootElement[0],
|
||||
rootElement[0].getHref().toString().substring(basePath.length())));
|
||||
|
||||
remoteFiles.add(webDavFileUtils.parseResponse(rootElement[0],
|
||||
Uri.parse(basePath)));
|
||||
|
||||
for (Response memberElement : memberElements) {
|
||||
remoteFiles.add(BrowserFile.Companion.getModelFromResponse(memberElement,
|
||||
memberElement.getHref().toString().substring(basePath.length())));
|
||||
browserFiles.add(BrowserFile.Companion.getModelFromResponse(memberElement,
|
||||
memberElement.getHref().toString().substring(basePath.length())));
|
||||
|
||||
remoteFiles.add(webDavFileUtils.parseResponse(memberElement,
|
||||
Uri.parse(basePath)));
|
||||
}
|
||||
|
||||
davResponse.setData(remoteFiles);
|
||||
|
@ -34,10 +34,6 @@ import at.bitfire.dav4jvm.property.GetContentType
|
||||
import at.bitfire.dav4jvm.property.GetLastModified
|
||||
import at.bitfire.dav4jvm.property.ResourceType
|
||||
import com.nextcloud.talk.components.filebrowser.models.DavResponse
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCEncrypted
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPermission
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPreview
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCFavorite
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCId
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCSize
|
||||
import com.nextcloud.talk.dagger.modules.RestModule.HttpAuthenticator
|
||||
@ -45,6 +41,11 @@ import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.remotefilebrowser.model.RemoteFileBrowserItem
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.Mimetype.FOLDER
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCEncrypted
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCFavorite
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCPermissions
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCPreview
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.OkHttpClient
|
||||
import java.io.File
|
||||
@ -70,7 +71,7 @@ class ReadFolderListingOperation(okHttpClient: OkHttpClient, currentUser: User,
|
||||
)
|
||||
)
|
||||
this.okHttpClient = okHttpClientBuilder.build()
|
||||
basePath = currentUser.baseUrl + DavUtils.DAV_PATH + currentUser.userId
|
||||
basePath = currentUser.baseUrl + ApiUtils.filesApi + currentUser.userId
|
||||
url = basePath + path
|
||||
this.depth = depth
|
||||
}
|
||||
@ -86,7 +87,7 @@ class ReadFolderListingOperation(okHttpClient: OkHttpClient, currentUser: User,
|
||||
url.toHttpUrlOrNull()!!
|
||||
).propfind(
|
||||
depth = depth,
|
||||
reqProp = DavUtils.getAllPropSet()
|
||||
reqProp = WebdavUtils.getAllPropertiesList()
|
||||
) { response: Response, hrefRelation: HrefRelation? ->
|
||||
davResponse.setResponse(response)
|
||||
when (hrefRelation) {
|
||||
@ -158,7 +159,7 @@ class ReadFolderListingOperation(okHttpClient: OkHttpClient, currentUser: User,
|
||||
is NCPreview -> {
|
||||
remoteFileBrowserItem.hasPreview = property.isNcPreview
|
||||
}
|
||||
is OCFavorite -> {
|
||||
is NCFavorite -> {
|
||||
remoteFileBrowserItem.isFavorite = property.isOcFavorite
|
||||
}
|
||||
is DisplayName -> {
|
||||
@ -167,8 +168,8 @@ class ReadFolderListingOperation(okHttpClient: OkHttpClient, currentUser: User,
|
||||
is NCEncrypted -> {
|
||||
remoteFileBrowserItem.isEncrypted = property.isNcEncrypted
|
||||
}
|
||||
is NCPermission -> {
|
||||
remoteFileBrowserItem.permissions = property.ncPermission
|
||||
is NCPermissions -> {
|
||||
remoteFileBrowserItem.permissions = property.permissions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,6 @@ import at.bitfire.dav4jvm.property.ResourceType
|
||||
import autodagger.AutoInjector
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.components.filebrowser.models.DavResponse
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCEncrypted
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPermission
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.NCPreview
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCFavorite
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCId
|
||||
import com.nextcloud.talk.components.filebrowser.models.properties.OCSize
|
||||
import com.nextcloud.talk.dagger.modules.RestModule
|
||||
@ -54,6 +50,10 @@ import com.nextcloud.talk.remotefilebrowser.model.RemoteFileBrowserItem
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.FileUtils
|
||||
import com.nextcloud.talk.utils.Mimetype
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCEncrypted
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCFavorite
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCPermissions
|
||||
import com.owncloud.android.lib.resources.files.webdav.NCPreview
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.OkHttpClient
|
||||
@ -355,6 +355,7 @@ class ChunkedFileUploader(
|
||||
}
|
||||
|
||||
@Suppress("Detekt.ComplexMethod")
|
||||
// TODO remove all of them and combine in library!
|
||||
private fun mapPropertyToBrowserFile(property: Property, remoteFileBrowserItem: RemoteFileBrowserItem) {
|
||||
when (property) {
|
||||
is OCId -> {
|
||||
@ -375,7 +376,7 @@ class ChunkedFileUploader(
|
||||
is NCPreview -> {
|
||||
remoteFileBrowserItem.hasPreview = property.isNcPreview
|
||||
}
|
||||
is OCFavorite -> {
|
||||
is NCFavorite -> {
|
||||
remoteFileBrowserItem.isFavorite = property.isOcFavorite
|
||||
}
|
||||
is DisplayName -> {
|
||||
@ -384,8 +385,8 @@ class ChunkedFileUploader(
|
||||
is NCEncrypted -> {
|
||||
remoteFileBrowserItem.isEncrypted = property.isNcEncrypted
|
||||
}
|
||||
is NCPermission -> {
|
||||
remoteFileBrowserItem.permissions = property.ncPermission
|
||||
is NCPermissions -> {
|
||||
remoteFileBrowserItem.permissions = property.permissions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ public class ApiUtils {
|
||||
private static final String ocsApiVersion = "/ocs/v2.php";
|
||||
private static final String spreedApiVersion = "/apps/spreed/api/v1";
|
||||
private static final String spreedApiBase = ocsApiVersion + "/apps/spreed/api/v";
|
||||
public static final String filesApi = "/remote.php/dav/files/";
|
||||
|
||||
private static final String userAgent = "Mozilla/5.0 (Android) Nextcloud-Talk v";
|
||||
|
||||
@ -421,7 +422,7 @@ public class ApiUtils {
|
||||
}
|
||||
|
||||
public static String getUrlForFileUpload(String baseUrl, String user, String remotePath) {
|
||||
return baseUrl + "/remote.php/dav/files/" + user + remotePath;
|
||||
return baseUrl + filesApi + user + remotePath;
|
||||
}
|
||||
|
||||
public static String getUrlForChunkedUpload(String baseUrl, String user) {
|
||||
@ -429,7 +430,7 @@ public class ApiUtils {
|
||||
}
|
||||
|
||||
public static String getUrlForFileDownload(String baseUrl, String user, String remotePath) {
|
||||
return baseUrl + "/remote.php/dav/files/" + user + "/" + remotePath;
|
||||
return baseUrl + filesApi + user + "/" + remotePath;
|
||||
}
|
||||
|
||||
public static String getUrlForTempAvatar(String baseUrl) {
|
||||
|
@ -25,6 +25,7 @@ buildscript {
|
||||
|
||||
ext {
|
||||
kotlinVersion = '1.9.10'
|
||||
androidLibraryVersion = "master-SNAPSHOT"
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -32,3 +32,9 @@ include ':app'
|
||||
// substitute module('com.github.nextcloud-deps:ImagePicker') using project(':imagepicker')
|
||||
// }
|
||||
//}
|
||||
|
||||
includeBuild('../android-library') {
|
||||
dependencySubstitution {
|
||||
substitute module('com.github.nextcloud:android-library') using project(':library')
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user