Fork dav4jvm

pull/1378/head
Alex Baker 3 years ago
parent 5f21bbc8cb
commit c88d2d759e

@ -147,7 +147,7 @@ val googleplayImplementation by configurations
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.1")
implementation("com.gitlab.bitfireAT:dav4jvm:2.1.1")
implementation("com.gitlab.abaker:dav4jvm:deb2c9aef8")
implementation("com.gitlab.abaker:ical4android:0e928b567c")
implementation("com.gitlab.bitfireAT:cert4android:26a91a729f")
implementation("com.github.dmfs.opentasks:opentasks-provider:1.2.4") {

@ -160,8 +160,8 @@ open class CaldavClient(
@Throws(IOException::class, XmlPullParserException::class, HttpException::class)
suspend fun updateCollection(displayName: String, color: Int): String = withContext(Dispatchers.IO) {
val davResource = PatchableDavResource(httpClient, httpUrl!!)
davResource.propPatch(getPropPatchString(displayName, color)) {}
val davResource = DavResource(httpClient, httpUrl!!)
davResource.proppatch(getPropPatchString(displayName, color)) { _, _ -> }
davResource.location.toString()
}

@ -283,7 +283,7 @@ class CaldavSynchronizer @Inject constructor(
try {
val remote = DavResource(
httpClient, httpUrl.newBuilder().addPathSegment(caldavTask.`object`!!).build())
remote.put(requestBody, null, false) {
remote.put(requestBody) {
val getETag = fromResponse(it)
if (getETag != null && !isNullOrEmpty(getETag.eTag)) {
caldavTask.etag = getETag.eTag

@ -1,69 +0,0 @@
package org.tasks.caldav
import at.bitfire.dav4jvm.DavResource
import at.bitfire.dav4jvm.DavResource.Companion.MAX_REDIRECTS
import at.bitfire.dav4jvm.exception.*
import okhttp3.*
import okhttp3.Response
import java.io.IOException
import java.net.HttpURLConnection
class PatchableDavResource(client: OkHttpClient, url: HttpUrl) : DavResource(client, url) {
/**
* Sends a PROPPATCH request to this resource. Follows up to [MAX_REDIRECTS] redirects.
*
* @throws IOException on I/O error
* @throws HttpException on HTTP error
*/
@Throws(IOException::class, HttpException::class)
fun propPatch(xmlBody: String?, callback: (response: Response) -> Unit) {
val rqBody = xmlBody?.let { RequestBody.create(MIME_XML, it) }
followRedirects {
httpClient.newCall(Request.Builder()
.method("PROPPATCH", rqBody)
.url(location)
.build()).execute()
}.use { response ->
checkStatus(response)
callback(response)
}
}
/**
* Checks the status from an HTTP response and throws an exception in case of an error.
*
* @throws HttpException in case of an HTTP error
*/
private fun checkStatus(response: Response) =
checkStatus(response.code, response.message, response)
/**
* Checks the status from an HTTP response and throws an exception in case of an error.
*
* @throws HttpException (with XML error names, if available) in case of an HTTP error
*/
private fun checkStatus(code: Int, message: String?, response: Response?) {
if (code / 100 == 2)
// everything OK
return
throw when (code) {
HttpURLConnection.HTTP_UNAUTHORIZED ->
if (response != null) UnauthorizedException(response) else UnauthorizedException(message)
HttpURLConnection.HTTP_FORBIDDEN ->
if (response != null) ForbiddenException(response) else ForbiddenException(message)
HttpURLConnection.HTTP_NOT_FOUND ->
if (response != null) NotFoundException(response) else NotFoundException(message)
HttpURLConnection.HTTP_CONFLICT ->
if (response != null) ConflictException(response) else ConflictException(message)
HttpURLConnection.HTTP_PRECON_FAILED ->
if (response != null) PreconditionFailedException(response) else PreconditionFailedException(message)
HttpURLConnection.HTTP_UNAVAILABLE ->
if (response != null) ServiceUnavailableException(response) else ServiceUnavailableException(message)
else ->
if (response != null) HttpException(response) else HttpException(code, message)
}
}
}

@ -15,16 +15,16 @@
++--- androidx.databinding:databinding-adapters:4.1.2
+| +--- androidx.databinding:databinding-common:4.1.2
+| \--- androidx.databinding:databinding-runtime:4.1.2 (*)
++--- com.gitlab.bitfireAT:dav4jvm:2.1.1
+| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.72 -> 1.4.30
++--- com.gitlab.abaker:dav4jvm:deb2c9aef8
+| +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.10 -> 1.4.30
+| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.4.30
+| | \--- org.jetbrains:annotations:13.0 -> 16.0.1
+| \--- org.apache.commons:commons-lang3:3.9
+| \--- org.apache.commons:commons-lang3:3.8.1
++--- com.gitlab.abaker:ical4android:0e928b567c
+| +--- org.mnode.ical4j:ical4j:3.0.21
+| | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
+| | +--- commons-codec:commons-codec:1.11
+| | +--- org.apache.commons:commons-lang3:3.8.1 -> 3.9
+| | +--- org.apache.commons:commons-lang3:3.8.1
+| | \--- org.apache.commons:commons-collections4:4.1
+| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.21
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.21 -> 1.4.30 (*)
@ -355,7 +355,7 @@
+| | \--- com.squareup.okhttp3:okhttp:3.12.1 -> 4.8.1 (*)
+| +--- com.google.code.gson:gson:1.7.2 -> 2.8.6
+| +--- org.apache.commons:commons-collections4:4.1
+| +--- org.apache.commons:commons-lang3:3.8.1 -> 3.9
+| +--- org.apache.commons:commons-lang3:3.8.1
+| \--- commons-codec:commons-codec:1.7 -> 1.11
++--- com.etebase:client:2.3.2
+| +--- androidx.annotation:annotation:1.1.0

@ -187,14 +187,14 @@
+| +--- com.google.android.gms:play-services-base:17.0.0 -> 17.3.0 (*)
+| \--- com.google.android.gms:play-services-basement:17.0.0 -> 17.3.0 (*)
++--- com.android.billingclient:billing:1.2.2
++--- com.gitlab.bitfireAT:dav4jvm:2.1.1
+| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.72 -> 1.4.30 (*)
+| \--- org.apache.commons:commons-lang3:3.9
++--- com.gitlab.abaker:dav4jvm:deb2c9aef8
+| +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.10 -> 1.4.30 (*)
+| \--- org.apache.commons:commons-lang3:3.8.1
++--- com.gitlab.abaker:ical4android:0e928b567c
+| +--- org.mnode.ical4j:ical4j:3.0.21
+| | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
+| | +--- commons-codec:commons-codec:1.11
+| | +--- org.apache.commons:commons-lang3:3.8.1 -> 3.9
+| | +--- org.apache.commons:commons-lang3:3.8.1
+| | \--- org.apache.commons:commons-collections4:4.1
+| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.21 (*)
+| +--- com.sun.mail:android-mail:1.6.5
@ -469,7 +469,7 @@
+| | \--- com.squareup.okhttp3:okhttp:3.12.1 -> 4.8.1 (*)
+| +--- com.google.code.gson:gson:1.7.2 -> 2.8.6
+| +--- org.apache.commons:commons-collections4:4.1
+| +--- org.apache.commons:commons-lang3:3.8.1 -> 3.9
+| +--- org.apache.commons:commons-lang3:3.8.1
+| \--- commons-codec:commons-codec:1.7 -> 1.11
++--- com.etebase:client:2.3.2
+| +--- androidx.annotation:annotation:1.1.0

Loading…
Cancel
Save