Loading README.md +3 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ dav4android is licensed under [Mozilla Public License, v. 2.0](LICENSE). For questions, suggestions etc. please use the DAVdroid forum: https://www.davdroid.com/forums/ If you want to contribute, please work in your own repository and then notify us on your changes so that we can backport them. Email: [play@bitfire.at](mailto:play@bitfire.at) Loading build.gradle +1 −1 Original line number Diff line number Diff line buildscript { ext.kotlin_version = '1.2.50' ext.kotlin_version = '1.2.51' ext.dokka_version = '0.9.16' repositories { Loading src/main/java/at/bitfire/dav4android/BasicDigestAuthHandler.kt +4 −3 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ package at.bitfire.dav4android import okhttp3.* import okhttp3.Response import okio.Buffer import okio.ByteString import java.io.IOException Loading @@ -23,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger * Authentication methods/credentials found to be working will be cached for further requests * (this is why the interceptor is needed). * * Usage: Set as authenticator **and** as network interceptor. * Usage: Set as authenticator *and* as network interceptor. */ class BasicDigestAuthHandler( /** Authenticate only against hosts ending with this domain (may be null, which means no restriction) */ Loading Loading @@ -54,8 +55,8 @@ class BasicDigestAuthHandler( } // cached authentication schemes var basicAuth: HttpUtils.AuthScheme? = null var digestAuth: HttpUtils.AuthScheme? = null private var basicAuth: HttpUtils.AuthScheme? = null private var digestAuth: HttpUtils.AuthScheme? = null fun authenticateRequest(request: Request, response: Response?): Request? { Loading src/main/java/at/bitfire/dav4android/DavAddressBook.kt +36 −25 Original line number Diff line number Diff line Loading @@ -24,14 +24,19 @@ class DavAddressBook @JvmOverloads constructor( val MIME_VCARD4 = MediaType.parse("text/vcard;version=4.0") } /** * Sends an addressbook-query REPORT request to the resource. * * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun addressbookQuery(): DavResponse { fun addressbookQuery(callback: DavResponseCallback): List<Property> { /* <!ELEMENT addressbook-query ((DAV:allprop | DAV:propname | DAV:prop)?, filter, limit?)> Loading @@ -53,25 +58,32 @@ class DavAddressBook @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CARDDAV, "addressbook-query") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", "1") .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { response -> return processMultiStatus(response, callback) } } /** * Sends an addressbook-multiget REPORT request to the resource. * * @param urls list of vCard URLs to be requested * @param vCard4 whether vCards should be requested as vCard4 4.0 (true: 4.0, false: 3.0) * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun multiget(urls: List<HttpUrl>, vCard4: Boolean): DavResponse { fun multiget(urls: List<HttpUrl>, vCard4: Boolean, callback: DavResponseCallback): List<Property> { /* <!ELEMENT addressbook-multiget ((DAV:allprop | DAV:propname | DAV:prop)?, Loading Loading @@ -104,16 +116,15 @@ class DavAddressBook @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CARDDAV, "addressbook-multiget") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", "0") // "The request MUST include a Depth: 0 header [...]" .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { return processMultiStatus(it, callback) } } } src/main/java/at/bitfire/dav4android/DavCalendar.kt +37 −23 Original line number Diff line number Diff line Loading @@ -34,11 +34,20 @@ class DavCalendar @JvmOverloads constructor( /** * Sends a calendar-query REPORT to the resource. * * @param component requested component name (like VEVENT or VTODO) * @param start time-range filter: start date (optional) * @param end time-range filter: end date (optional) * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun calendarQuery(component: String, start: Date?, end: Date?): DavResponse { fun calendarQuery(component: String, start: Date?, end: Date?, callback: DavResponseCallback): List<Property> { /* <!ELEMENT calendar-query ((DAV:allprop | DAV:propname | DAV:prop)?, filter, timezone?)> Loading Loading @@ -80,25 +89,31 @@ class DavCalendar @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CALDAV, "calendar-query") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", "1") .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { return processMultiStatus(it, callback) } } /** * Sends a calendar-multiget REPORT to the resource. * * @param urls list of iCalendar URLs to be requested * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun multiget(urls: List<HttpUrl>): DavResponse { fun multiget(urls: List<HttpUrl>, callback: DavResponseCallback): List<Property> { /* <!ELEMENT calendar-multiget ((DAV:allprop | DAV:propname | DAV:prop)?, DAV:href+)> Loading Loading @@ -126,15 +141,14 @@ class DavCalendar @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CALDAV, "calendar-multiget") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { return processMultiStatus(it, callback) } } } Loading
README.md +3 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ dav4android is licensed under [Mozilla Public License, v. 2.0](LICENSE). For questions, suggestions etc. please use the DAVdroid forum: https://www.davdroid.com/forums/ If you want to contribute, please work in your own repository and then notify us on your changes so that we can backport them. Email: [play@bitfire.at](mailto:play@bitfire.at) Loading
build.gradle +1 −1 Original line number Diff line number Diff line buildscript { ext.kotlin_version = '1.2.50' ext.kotlin_version = '1.2.51' ext.dokka_version = '0.9.16' repositories { Loading
src/main/java/at/bitfire/dav4android/BasicDigestAuthHandler.kt +4 −3 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ package at.bitfire.dav4android import okhttp3.* import okhttp3.Response import okio.Buffer import okio.ByteString import java.io.IOException Loading @@ -23,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger * Authentication methods/credentials found to be working will be cached for further requests * (this is why the interceptor is needed). * * Usage: Set as authenticator **and** as network interceptor. * Usage: Set as authenticator *and* as network interceptor. */ class BasicDigestAuthHandler( /** Authenticate only against hosts ending with this domain (may be null, which means no restriction) */ Loading Loading @@ -54,8 +55,8 @@ class BasicDigestAuthHandler( } // cached authentication schemes var basicAuth: HttpUtils.AuthScheme? = null var digestAuth: HttpUtils.AuthScheme? = null private var basicAuth: HttpUtils.AuthScheme? = null private var digestAuth: HttpUtils.AuthScheme? = null fun authenticateRequest(request: Request, response: Response?): Request? { Loading
src/main/java/at/bitfire/dav4android/DavAddressBook.kt +36 −25 Original line number Diff line number Diff line Loading @@ -24,14 +24,19 @@ class DavAddressBook @JvmOverloads constructor( val MIME_VCARD4 = MediaType.parse("text/vcard;version=4.0") } /** * Sends an addressbook-query REPORT request to the resource. * * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun addressbookQuery(): DavResponse { fun addressbookQuery(callback: DavResponseCallback): List<Property> { /* <!ELEMENT addressbook-query ((DAV:allprop | DAV:propname | DAV:prop)?, filter, limit?)> Loading @@ -53,25 +58,32 @@ class DavAddressBook @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CARDDAV, "addressbook-query") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", "1") .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { response -> return processMultiStatus(response, callback) } } /** * Sends an addressbook-multiget REPORT request to the resource. * * @param urls list of vCard URLs to be requested * @param vCard4 whether vCards should be requested as vCard4 4.0 (true: 4.0, false: 3.0) * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun multiget(urls: List<HttpUrl>, vCard4: Boolean): DavResponse { fun multiget(urls: List<HttpUrl>, vCard4: Boolean, callback: DavResponseCallback): List<Property> { /* <!ELEMENT addressbook-multiget ((DAV:allprop | DAV:propname | DAV:prop)?, Loading Loading @@ -104,16 +116,15 @@ class DavAddressBook @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CARDDAV, "addressbook-multiget") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", "0") // "The request MUST include a Depth: 0 header [...]" .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { return processMultiStatus(it, callback) } } }
src/main/java/at/bitfire/dav4android/DavCalendar.kt +37 −23 Original line number Diff line number Diff line Loading @@ -34,11 +34,20 @@ class DavCalendar @JvmOverloads constructor( /** * Sends a calendar-query REPORT to the resource. * * @param component requested component name (like VEVENT or VTODO) * @param start time-range filter: start date (optional) * @param end time-range filter: end date (optional) * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun calendarQuery(component: String, start: Date?, end: Date?): DavResponse { fun calendarQuery(component: String, start: Date?, end: Date?, callback: DavResponseCallback): List<Property> { /* <!ELEMENT calendar-query ((DAV:allprop | DAV:propname | DAV:prop)?, filter, timezone?)> Loading Loading @@ -80,25 +89,31 @@ class DavCalendar @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CALDAV, "calendar-query") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", "1") .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { return processMultiStatus(it, callback) } } /** * Sends a calendar-multiget REPORT to the resource. * * @param urls list of iCalendar URLs to be requested * @param callback called for every WebDAV response XML element in the result * * @return list of properties which have been received in the Multi-Status response, but * are not part of response XML elements * * @throws IOException on I/O error * @throws HttpException on HTTP error * @throws DavException on DAV error * @throws DavException on WebDAV error */ fun multiget(urls: List<HttpUrl>): DavResponse { fun multiget(urls: List<HttpUrl>, callback: DavResponseCallback): List<Property> { /* <!ELEMENT calendar-multiget ((DAV:allprop | DAV:propname | DAV:prop)?, DAV:href+)> Loading Loading @@ -126,15 +141,14 @@ class DavCalendar @JvmOverloads constructor( serializer.endTag(XmlUtils.NS_CALDAV, "calendar-multiget") serializer.endDocument() val response = httpClient.newCall(Request.Builder() followRedirects { httpClient.newCall(Request.Builder() .url(location) .method("REPORT", RequestBody.create(MIME_XML, writer.toString())) .build()).execute() checkStatus(response) assertMultiStatus(response) return processMultiStatus(response.body()?.charStream()!!) }.use { return processMultiStatus(it, callback) } } }