mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Added a new property, so that, we can retrieve the shares within the propfind
This commit is contained in:
parent
2dc6f30a5e
commit
5be4eca0f7
@ -26,10 +26,11 @@ package com.owncloud.android.lib.common.http.methods.webdav
|
|||||||
import at.bitfire.dav4jvm.Property
|
import at.bitfire.dav4jvm.Property
|
||||||
import at.bitfire.dav4jvm.PropertyUtils.getAllPropSet
|
import at.bitfire.dav4jvm.PropertyUtils.getAllPropSet
|
||||||
import at.bitfire.dav4jvm.PropertyUtils.getQuotaPropset
|
import at.bitfire.dav4jvm.PropertyUtils.getQuotaPropset
|
||||||
|
import com.owncloud.android.lib.common.http.methods.webdav.properties.OCShareTypes
|
||||||
|
|
||||||
object DavUtils {
|
object DavUtils {
|
||||||
@JvmStatic val allPropset: Array<Property.Name>
|
@JvmStatic val allPropset: Array<Property.Name>
|
||||||
get() = getAllPropSet()
|
get() = getAllPropSet().plus(OCShareTypes.NAME)
|
||||||
|
|
||||||
val quotaPropSet: Array<Property.Name>
|
val quotaPropSet: Array<Property.Name>
|
||||||
get() = getQuotaPropset()
|
get() = getQuotaPropset()
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/* ownCloud Android Library is available under MIT license
|
||||||
|
* Copyright (C) 2022 ownCloud 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.common.http.methods.webdav.properties
|
||||||
|
|
||||||
|
import at.bitfire.dav4jvm.Property
|
||||||
|
import at.bitfire.dav4jvm.XmlUtils
|
||||||
|
import org.xmlpull.v1.XmlPullParser
|
||||||
|
|
||||||
|
class OCShareTypes : ShareTypeListProperty() {
|
||||||
|
|
||||||
|
class Factory : ShareTypeListProperty.Factory() {
|
||||||
|
|
||||||
|
override fun create(parser: XmlPullParser) =
|
||||||
|
create(parser, OCShareTypes())
|
||||||
|
|
||||||
|
override fun getName(): Property.Name = NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmField
|
||||||
|
val NAME = Property.Name(XmlUtils.NS_OWNCLOUD, "share-types")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/* ownCloud Android Library is available under MIT license
|
||||||
|
* Copyright (C) 2022 ownCloud 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.common.http.methods.webdav.properties
|
||||||
|
|
||||||
|
import at.bitfire.dav4jvm.Property
|
||||||
|
import at.bitfire.dav4jvm.PropertyFactory
|
||||||
|
import at.bitfire.dav4jvm.XmlUtils
|
||||||
|
import org.xmlpull.v1.XmlPullParser
|
||||||
|
import java.util.LinkedList
|
||||||
|
|
||||||
|
abstract class ShareTypeListProperty : Property {
|
||||||
|
|
||||||
|
val shareTypes = LinkedList<String>()
|
||||||
|
|
||||||
|
override fun toString() = "share types =[" + shareTypes.joinToString(", ") + "]"
|
||||||
|
|
||||||
|
abstract class Factory : PropertyFactory {
|
||||||
|
|
||||||
|
fun create(parser: XmlPullParser, list: ShareTypeListProperty): ShareTypeListProperty {
|
||||||
|
XmlUtils.readTextPropertyList(parser, Property.Name(XmlUtils.NS_OWNCLOUD, "share-type"), list.shareTypes)
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.files;
|
package com.owncloud.android.lib.resources.files;
|
||||||
|
|
||||||
|
import at.bitfire.dav4jvm.PropertyRegistry;
|
||||||
import at.bitfire.dav4jvm.Response;
|
import at.bitfire.dav4jvm.Response;
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||||
@ -31,6 +32,7 @@ import com.owncloud.android.lib.common.http.HttpConstants;
|
|||||||
import com.owncloud.android.lib.common.http.methods.webdav.DavConstants;
|
import com.owncloud.android.lib.common.http.methods.webdav.DavConstants;
|
||||||
import com.owncloud.android.lib.common.http.methods.webdav.DavUtils;
|
import com.owncloud.android.lib.common.http.methods.webdav.DavUtils;
|
||||||
import com.owncloud.android.lib.common.http.methods.webdav.PropfindMethod;
|
import com.owncloud.android.lib.common.http.methods.webdav.PropfindMethod;
|
||||||
|
import com.owncloud.android.lib.common.http.methods.webdav.properties.OCShareTypes;
|
||||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
@ -72,6 +74,7 @@ public class ReadRemoteFolderOperation extends RemoteOperation<ArrayList<RemoteF
|
|||||||
RemoteOperationResult<ArrayList<RemoteFile>> result = null;
|
RemoteOperationResult<ArrayList<RemoteFile>> result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
PropertyRegistry.INSTANCE.register(OCShareTypes.Factory.class.newInstance());
|
||||||
PropfindMethod propfindMethod = new PropfindMethod(
|
PropfindMethod propfindMethod = new PropfindMethod(
|
||||||
new URL(client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mRemotePath)),
|
new URL(client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mRemotePath)),
|
||||||
DavConstants.DEPTH_1,
|
DavConstants.DEPTH_1,
|
||||||
|
@ -40,10 +40,14 @@ import at.bitfire.dav4jvm.property.OCPrivatelink;
|
|||||||
import at.bitfire.dav4jvm.property.OCSize;
|
import at.bitfire.dav4jvm.property.OCSize;
|
||||||
import at.bitfire.dav4jvm.property.QuotaAvailableBytes;
|
import at.bitfire.dav4jvm.property.QuotaAvailableBytes;
|
||||||
import at.bitfire.dav4jvm.property.QuotaUsedBytes;
|
import at.bitfire.dav4jvm.property.QuotaUsedBytes;
|
||||||
|
import com.owncloud.android.lib.common.http.methods.webdav.properties.OCShareTypes;
|
||||||
|
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,6 +89,8 @@ public class RemoteFile implements Parcelable, Serializable {
|
|||||||
private BigDecimal mQuotaUsedBytes;
|
private BigDecimal mQuotaUsedBytes;
|
||||||
private BigDecimal mQuotaAvailableBytes;
|
private BigDecimal mQuotaAvailableBytes;
|
||||||
private String mPrivateLink;
|
private String mPrivateLink;
|
||||||
|
private boolean mSharedByLink;
|
||||||
|
private boolean mSharedWithSharee;
|
||||||
|
|
||||||
public RemoteFile() {
|
public RemoteFile() {
|
||||||
resetData();
|
resetData();
|
||||||
@ -153,6 +159,23 @@ public class RemoteFile implements Parcelable, Serializable {
|
|||||||
if (property instanceof OCPrivatelink) {
|
if (property instanceof OCPrivatelink) {
|
||||||
this.setPrivateLink(((OCPrivatelink) property).getLink());
|
this.setPrivateLink(((OCPrivatelink) property).getLink());
|
||||||
}
|
}
|
||||||
|
if (property instanceof OCShareTypes) {
|
||||||
|
LinkedList<String> list = ((OCShareTypes) property).getShareTypes();
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
ShareType shareType = ShareType.Companion.fromValue(Integer.parseInt(list.get(i)));
|
||||||
|
if (shareType == null) {
|
||||||
|
Timber.d("Illegal share type value: " + list.get(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (shareType.equals(ShareType.PUBLIC_LINK)) {
|
||||||
|
this.setSharedViaLink(true);
|
||||||
|
} else if (shareType.equals(ShareType.USER) ||
|
||||||
|
shareType.equals(ShareType.FEDERATED) ||
|
||||||
|
shareType.equals(ShareType.GROUP)) {
|
||||||
|
this.setSharedWithSharee(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,6 +289,22 @@ public class RemoteFile implements Parcelable, Serializable {
|
|||||||
mPrivateLink = privateLink;
|
mPrivateLink = privateLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSharedWithSharee(boolean shareWithSharee) {
|
||||||
|
mSharedWithSharee = shareWithSharee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSharedWithSharee() {
|
||||||
|
return mSharedWithSharee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSharedViaLink(boolean sharedViaLink) {
|
||||||
|
mSharedByLink = sharedViaLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSharedByLink() {
|
||||||
|
return mSharedByLink;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used internally. Reset all file properties
|
* Used internally. Reset all file properties
|
||||||
*/
|
*/
|
||||||
@ -282,6 +321,8 @@ public class RemoteFile implements Parcelable, Serializable {
|
|||||||
mQuotaUsedBytes = null;
|
mQuotaUsedBytes = null;
|
||||||
mQuotaAvailableBytes = null;
|
mQuotaAvailableBytes = null;
|
||||||
mPrivateLink = null;
|
mPrivateLink = null;
|
||||||
|
mSharedWithSharee = false;
|
||||||
|
mSharedByLink = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromParcel(Parcel source) {
|
public void readFromParcel(Parcel source) {
|
||||||
@ -319,4 +360,4 @@ public class RemoteFile implements Parcelable, Serializable {
|
|||||||
dest.writeSerializable(mQuotaAvailableBytes);
|
dest.writeSerializable(mQuotaAvailableBytes);
|
||||||
dest.writeString(mPrivateLink);
|
dest.writeString(mPrivateLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user