mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
caldav: add support for reports
Co-authored-by: Conrad Hoffmann <ch@bitfehler.net>
This commit is contained in:
parent
85d2b222bb
commit
9caa4ff356
@ -2,6 +2,7 @@ package caldav
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/emersion/go-webdav/internal"
|
"github.com/emersion/go-webdav/internal"
|
||||||
@ -12,9 +13,13 @@ const namespace = "urn:ietf:params:xml:ns:caldav"
|
|||||||
var (
|
var (
|
||||||
calendarHomeSetName = xml.Name{namespace, "calendar-home-set"}
|
calendarHomeSetName = xml.Name{namespace, "calendar-home-set"}
|
||||||
|
|
||||||
calendarDescriptionName = xml.Name{namespace, "calendar-description"}
|
calendarDescriptionName = xml.Name{namespace, "calendar-description"}
|
||||||
supportedCalendarDataName = xml.Name{namespace, "supported-calendar-data"}
|
supportedCalendarDataName = xml.Name{namespace, "supported-calendar-data"}
|
||||||
maxResourceSizeName = xml.Name{namespace, "max-resource-size"}
|
supportedCalendarComponentSetName = xml.Name{namespace, "supported-calendar-component-set"}
|
||||||
|
maxResourceSizeName = xml.Name{namespace, "max-resource-size"}
|
||||||
|
|
||||||
|
calendarQueryName = xml.Name{namespace, "calendar-query"}
|
||||||
|
calendarMultigetName = xml.Name{namespace, "calendar-multiget"}
|
||||||
|
|
||||||
calendarName = xml.Name{namespace, "calendar"}
|
calendarName = xml.Name{namespace, "calendar"}
|
||||||
)
|
)
|
||||||
@ -37,6 +42,12 @@ type supportedCalendarData struct {
|
|||||||
Types []calendarDataType `xml:"calendar-data"`
|
Types []calendarDataType `xml:"calendar-data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://tools.ietf.org/html/rfc4791#section-5.2.3
|
||||||
|
type supportedCalendarComponentSet struct {
|
||||||
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav supported-calendar-component-set"`
|
||||||
|
Comp []comp `xml:"comp"`
|
||||||
|
}
|
||||||
|
|
||||||
// https://tools.ietf.org/html/rfc4791#section-9.6
|
// https://tools.ietf.org/html/rfc4791#section-9.6
|
||||||
type calendarDataType struct {
|
type calendarDataType struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
|
||||||
@ -160,3 +171,25 @@ type calendarDataResp struct {
|
|||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
|
||||||
Data []byte `xml:",chardata"`
|
Data []byte `xml:",chardata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type reportReq struct {
|
||||||
|
Query *calendarQuery
|
||||||
|
Multiget *calendarMultiget
|
||||||
|
// TODO: CALDAV:free-busy-query
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *reportReq) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
||||||
|
var v interface{}
|
||||||
|
switch start.Name {
|
||||||
|
case calendarQueryName:
|
||||||
|
r.Query = &calendarQuery{}
|
||||||
|
v = r.Query
|
||||||
|
case calendarMultigetName:
|
||||||
|
r.Multiget = &calendarMultiget{}
|
||||||
|
v = r.Multiget
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("caldav: unsupported REPORT root %q %q", start.Name.Space, start.Name.Local)
|
||||||
|
}
|
||||||
|
|
||||||
|
return d.DecodeElement(v, &start)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user