Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit c63dd3b3 authored by Ricki Hirner's avatar Ricki Hirner Committed by GitHub
Browse files

Allow calendar-query to fetch arbitrary WebDAV properties (#159)

* Update calendar-query to support custom WebDAV properties

- Add `props` parameter to `calendarQuery` method with default value of `{WebDAV.GetETag}`
- Replace hardcoded `WebDAV.GetETag` with dynamic property insertion based on `props` parameter

* Update calendar-query documentation to clarify default properties and full iCalendar retrieval

- Clarify that default `props` parameter uses `[WebDAV.GetETag]`
- Specify that `[CalDAV.CalendarData]` is required for full iCalendar data
parent 983c969e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2,5 +2,13 @@
  <code_scheme name="Project" version="173">
    <option name="LINE_SEPARATOR" value="&#10;" />
    <option name="RIGHT_MARGIN" value="180" />
    <JetCodeStyleSettings>
      <option name="PACKAGES_TO_USE_STAR_IMPORTS">
        <value>
          <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
          <package name="io.ktor" alias="false" withSubpackages="true" />
        </value>
      </option>
    </JetCodeStyleSettings>
  </code_scheme>
</component>
 No newline at end of file
+8 −11
Original line number Diff line number Diff line
@@ -16,16 +16,10 @@ import at.bitfire.dav4jvm.XmlUtils.insertTag
import at.bitfire.dav4jvm.property.caldav.CalDAV
import at.bitfire.dav4jvm.property.caldav.CalendarData
import at.bitfire.dav4jvm.property.webdav.WebDAV
import io.ktor.client.HttpClient
import io.ktor.client.request.header
import io.ktor.client.request.prepareRequest
import io.ktor.client.request.setBody
import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import io.ktor.http.Url
import io.ktor.http.contentType
import io.ktor.util.logging.Logger
import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.util.logging.*
import org.slf4j.LoggerFactory
import java.io.StringWriter
import java.time.Instant
@@ -47,6 +41,7 @@ class DavCalendar(
     * @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 props     requested WebDAV properties for results (default: only [WebDAV.GetETag]; use [CalDAV.CalendarData] to receive full iCalendars)
     * @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
@@ -60,6 +55,7 @@ class DavCalendar(
        component: String,
        start: Instant?,
        end: Instant?,
        props: Set<Property.Name> = setOf(WebDAV.GetETag),
        callback: MultiResponseCallback
    ): List<Property> {
        /* <!ELEMENT calendar-query ((DAV:allprop |
@@ -81,7 +77,8 @@ class DavCalendar(
        serializer.setPrefix("CAL", CalDAV.NS_CALDAV)
        serializer.insertTag(CalDAV.CalendarQuery) {
            insertTag(WebDAV.Prop) {
                insertTag(WebDAV.GetETag)
                for (prop in props)
                    insertTag(prop)
            }
            insertTag(CalDAV.Filter) {
                insertTag(CalDAV.CompFilter) {