Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPDATED] Added expand request #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions caldav/caldav.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ type CalendarCompRequest struct {

AllComps bool
Comps []CalendarCompRequest

Expand *CalendarExpandRequest
}

type CalendarExpandRequest struct {
Start, End time.Time
}

type CompFilter struct {
Expand Down
15 changes: 14 additions & 1 deletion caldav/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ func encodeCalendarReq(c *CalendarCompRequest) (*internal.Prop, error) {
return nil, err
}

calDataReq := calendarDataReq{Comp: compReq}
expandReq := encodeExpandRequest(c.Expand)

calDataReq := calendarDataReq{Comp: compReq, Expand: expandReq}

getLastModReq := internal.NewRawXMLElement(internal.GetLastModifiedName, nil, nil)
getETagReq := internal.NewRawXMLElement(internal.GetETagName, nil, nil)
Expand All @@ -175,6 +177,17 @@ func encodeCompFilter(filter *CompFilter) *compFilter {
return &encoded
}

func encodeExpandRequest(e *CalendarExpandRequest) *expand {
if e == nil {
return nil
}
encoded := expand{
Start: dateWithUTCTime(e.Start),
End: dateWithUTCTime(e.End),
}
return &encoded
}

func decodeCalendarObjectList(ms *internal.MultiStatus) ([]CalendarObject, error) {
addrs := make([]CalendarObject, 0, len(ms.Responses))
for _, resp := range ms.Responses {
Expand Down
9 changes: 8 additions & 1 deletion caldav/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ func (t *dateWithUTCTime) MarshalText() ([]byte, error) {
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
Expand *expand `xml:"expand,omitempty"`
// TODO: limit-recurrence-set, limit-freebusy-set
}

// https://tools.ietf.org/html/rfc4791#section-9.6.1
Expand All @@ -194,6 +195,12 @@ type comp struct {
Comp []comp `xml:"comp,omitempty"`
}

type expand struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav expand"`
Start dateWithUTCTime `xml:"start,attr"`
End dateWithUTCTime `xml:"end,attr"`
}

// https://tools.ietf.org/html/rfc4791#section-9.6.4
type prop struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav prop"`
Expand Down