go-webdav/caldav/elements.go

92 lines
2.9 KiB
Go
Raw Normal View History

2020-01-30 12:18:05 +00:00
package caldav
import (
"encoding/xml"
"github.com/emersion/go-webdav/internal"
)
const namespace = "urn:ietf:params:xml:ns:caldav"
2020-01-30 12:28:32 +00:00
var (
calendarHomeSetName = xml.Name{namespace, "calendar-home-set"}
calendarDescriptionName = xml.Name{namespace, "calendar-description"}
supportedCalendarDataName = xml.Name{namespace, "supported-calendar-data"}
maxResourceSizeName = xml.Name{namespace, "max-resource-size"}
2020-01-30 12:51:02 +00:00
calendarName = xml.Name{namespace, "calendar"}
2020-01-30 12:28:32 +00:00
)
2020-01-30 12:18:05 +00:00
// https://tools.ietf.org/html/rfc4791#section-6.2.1
type calendarHomeSet struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-home-set"`
Href internal.Href `xml:"DAV: href"`
}
2020-01-30 12:28:32 +00:00
// https://tools.ietf.org/html/rfc4791#section-5.2.1
type calendarDescription struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-description"`
Description string `xml:",chardata"`
}
// https://tools.ietf.org/html/rfc4791#section-5.2.4
type supportedCalendarData struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav supported-calendar-data"`
Types []calendarDataType `xml:"calendar-data"`
}
// https://tools.ietf.org/html/rfc4791#section-9.6
type calendarDataType struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
ContentType string `xml:"content-type,attr"`
Version string `xml:"version,attr"`
}
// https://tools.ietf.org/html/rfc4791#section-5.2.5
type maxResourceSize struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav max-resource-size"`
Size int64 `xml:",chardata"`
}
// https://tools.ietf.org/html/rfc4791#section-9.5
type calendarQuery struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-query"`
Prop *internal.Prop `xml:"DAV: prop,omitempty"`
AllProp *struct{} `xml:"DAV: allprop,omitempty"`
PropName *struct{} `xml:"DAV: propname,omitempty"`
// TODO: filter, timezone
}
// Request variant of https://tools.ietf.org/html/rfc4791#section-9.6
type calendarDataReq struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
Comp *comp `xml:"comp,omitempty"`
// TODO: expand, limit-recurrence-set, limit-freebusy-set
}
// https://tools.ietf.org/html/rfc4791#section-9.6.1
type comp struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav comp"`
Name string `xml:"name,attr"`
Allprop *struct{} `xml:"allprop,omitempty"`
Prop []prop `xml:"prop,omitempty"`
Allcomp *struct{} `xml:"allcomp,omitempty"`
Comp []comp `xml:"comp,omitempty"`
}
// https://tools.ietf.org/html/rfc4791#section-9.6.4
type prop struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav prop"`
Name string `xml:"name,attr"`
// TODO: novalue
}
// Response variant of https://tools.ietf.org/html/rfc4791#section-9.6
2020-02-03 16:26:55 +00:00
type calendarDataResp struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
Data []byte `xml:",chardata"`
}